Class: Resync::XML::ChangefreqNode

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

Overview

Maps Resync::Types::Changefreq values.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ChangefreqNode

Returns a new instance of ChangefreqNode.



134
135
136
137
138
# File 'lib/resync/xml.rb', line 134

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.



141
142
143
# File 'lib/resync/xml.rb', line 141

def extract_attr_value(xml)
  Resync::Types::ChangeFrequency.parse(default_when_xpath_err { @path.first(xml).text })
end

#set_attr_value(xml, value) ⇒ Object

Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.



146
147
148
# File 'lib/resync/xml.rb', line 146

def set_attr_value(xml, value)
  @path.first(xml, ensure_created: true).text = value.to_s
end