method
add_text
add_text( text )
public
A helper method to add a Text child. Actual Text instances can be added with regular Parent methods, such as add() and <<()
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.