[前][次][番号順一覧][スレッド一覧]

ruby-changes:29766

From: kou <ko1@a...>
Date: Sun, 7 Jul 2013 11:48:45 +0900 (JST)
Subject: [ruby-changes:29766] kou:r41818 (trunk): * lib/rexml/text.rb (REXML::Text#<<): Support method chain use by "<<"

kou	2013-07-07 11:48:35 +0900 (Sun, 07 Jul 2013)

  New Revision: 41818

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41818

  Log:
    * lib/rexml/text.rb (REXML::Text#<<): Support method chain use by "<<"
      like other objects.
    * test/rexml/test_text.rb (TextTester#test_shift_operator_chain):
      Add a test for the above case.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/text.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41817)
+++ ChangeLog	(revision 41818)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul  7 11:43:13 2013  Kouhei Sutou  <kou@c...>
+
+	* lib/rexml/text.rb (REXML::Text#<<): Support method chain use by "<<"
+	  like other objects.
+	* test/rexml/test_text.rb (TextTester#test_shift_operator_chain):
+	  Add a test for the above case.
+
 Sun Jul  7 11:34:18 2013  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/text.rb (REXML::Text#clear_cache): Extract common
Index: lib/rexml/text.rb
===================================================================
--- lib/rexml/text.rb	(revision 41817)
+++ lib/rexml/text.rb	(revision 41818)
@@ -186,8 +186,12 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/text.rb#L186
 
     # Appends text to this text node.  The text is appended in the +raw+ mode
     # of this text node.
+    #
+    # +returns+ the text itself to enable method chain like
+    # 'text << "XXX" << "YYY"'.
     def <<( to_append )
       @string << to_append.gsub( /\r\n?/, "\n" )
+      self
     end
 
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]