Method: RTF::TextNode#insert
- Defined in:
- lib/rtf/node.rb
#insert(text, offset) ⇒ Object
This method inserts a String into the existing text within a TextNode object. If the TextNode contains no text then it is simply set to the text passed in. If the offset specified is past the end of the nodes text then it is simply appended to the end.
Parameters
- text
-
A String containing the text to be added.
- offset
-
The numbers of characters from the first character to insert the new text at.
113 114 115 116 117 118 119 |
# File 'lib/rtf/node.rb', line 113 def insert(text, offset) if @text != nil @text = @text[0, offset] + text.to_s + @text[offset, @text.length] else @text = text.to_s end end |