add_text

add_text( text )
Instance Public methods

A helper method to add a Text child. Actual Text instances can be added with regular Parent methods, such as add() and <<()

text

if a String, a new Text instance is created and added to the parent. If Text, the object is added directly.

Returns

this Element

e = Element.new('a')          #-> <e/>
e.add_text 'foo'              #-> <e>foo</e>
e.add_text Text.new(' bar')    #-> <e>foo bar</e>

Note that at the end of this example, the branch has 3 nodes; the 'e' element and 2 Text node children.

doc_ruby_on_rails
2015-05-06 09:57:46
Comments
Leave a Comment

Please login to continue.