Class: ROXML::XMLTextRef

Inherits:
XMLRef
  • Object
show all
Defined in:
lib/roxml/xml/references.rb

Overview

Interal class representing XML content text binding

In context:

<element attribute="XMLAttributeRef">
 XMLTextRef
</element>

Direct Known Subclasses

XMLHashRef, XMLObjectRef

Instance Attribute Summary

Attributes inherited from XMLRef

#opts

Instance Method Summary collapse

Methods inherited from XMLRef

#blocks, #initialize, #name, #to_xml, #value_in, #xpath_name

Constructor Details

This class inherits a constructor from ROXML::XMLRef

Instance Method Details

#update_xml(xml, value) ⇒ Object

Updates the text in the given xml block to the value provided.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/roxml/xml/references.rb', line 172

def update_xml(xml, value)
  wrap(xml).tap do |xml|
    if content?
      add(xml, value)
    elsif name?
      xml.name = value
    elsif array?
      value.each do |v|
        add(XML.add_node(xml, name), v)
      end
    else
      add(XML.add_node(xml, name), value)
    end
  end
end