Class: Resync::XML::UriNode

Inherits:
XML::Mapping::SingleAttributeNode
  • Object
show all
Defined in:
lib/resync/xml.rb

Overview

Maps URI objects.

Instance Method Summary collapse

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