Class: LabelFactory::Util::LengthNode

Inherits:
XML::Mapping::SingleAttributeNode
  • Object
show all
Defined in:
lib/label_factory/util/length_node.rb

Instance Method Summary collapse

Instance Method Details

#extract_attr_value(xml) ⇒ Object



9
10
11
12
# File 'lib/label_factory/util/length_node.rb', line 9

def extract_attr_value(xml)
  @value = default_when_xpath_err{@path.first(xml).text}
Layout::Length.new(@value)
end

#initialize_impl(path) ⇒ Object



5
6
7
# File 'lib/label_factory/util/length_node.rb', line 5

def initialize_impl(path)
  @path = XML::XXPath.new(path)
end

#set_attr_value(xml, value) ⇒ Object



14
15
16
17
# File 'lib/label_factory/util/length_node.rb', line 14

def set_attr_value(xml, value)
  raise "Not a Length: #{value}" unless value.is_a? Layout::Length
  @path.first(xml, ensure_created: true).text = value.value
end