Class: Resync::XML::UriNode
- Inherits:
-
XML::Mapping::SingleAttributeNode
- Object
- XML::Mapping::SingleAttributeNode
- Resync::XML::UriNode
- Defined in:
- lib/resync/xml.rb
Overview
Maps URI objects.
Instance Method Summary collapse
-
#extract_attr_value(xml) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#extract_attr_value.
-
#initialize(*args) ⇒ UriNode
constructor
A new instance of UriNode.
-
#set_attr_value(xml, value) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.
Constructor Details
#initialize(*args) ⇒ UriNode
Returns a new instance of UriNode.
88 89 90 91 92 |
# File 'lib/resync/xml.rb', line 88 def initialize(*args) path, *args = super(*args) @path = ::XML::XXPath.new(path) args end |
Instance Method Details
#extract_attr_value(xml) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#extract_attr_value.
95 96 97 98 |
# File 'lib/resync/xml.rb', line 95 def extract_attr_value(xml) val = default_when_xpath_err { @path.first(xml).text } URI(val.strip) end |
#set_attr_value(xml, value) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.
101 102 103 |
# File 'lib/resync/xml.rb', line 101 def set_attr_value(xml, value) @path.first(xml, ensure_created: true).text = value.to_s end |