Method: Ox::Element#replace_text
- Defined in:
- lib/ox/element.rb
#replace_text(txt) ⇒ Object
Clears any child nodes of an element and replaces those with a single Text (String) node. Note the existing nodes array is modified and not replaced.
-
txt[String] to become the only element of the nodes array
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ox/element.rb', line 100 def replace_text(txt) raise 'the argument to replace_text() must be a String' unless txt.is_a?(String) if !instance_variable_defined?(:@nodes) or @nodes.nil? @node = [] else @nodes.clear end @nodes << txt end |