Class: VORuby::VOResource::Mapping::NumericEnumerationNode
- Inherits:
-
XML::Mapping::NumericNode
- Object
- XML::Mapping::NumericNode
- VORuby::VOResource::Mapping::NumericEnumerationNode
- Includes:
- Misc
- Defined in:
- lib/voruby/resources/nodes.rb
Instance Method Summary collapse
Methods included from Misc
Instance Method Details
#extract_attr_value(xml) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/voruby/resources/nodes.rb', line 71 def extract_attr_value(xml) txt = default_when_xpath_err{ @path.first(xml).text } num = nil begin num = Integer(txt) rescue ArgumentError num = Float(txt) end self.raise_error(txt) if !@options[:choices].include?(num) return num end |
#set_attr_value(xml, value) ⇒ Object
86 87 88 89 90 |
# File 'lib/voruby/resources/nodes.rb', line 86 def set_attr_value(xml, value) raise RuntimeError, "Not an integer: #{value}" unless Numeric === value self.raise_error(value) unless @options[:choices].include?(value) @path.first(xml,:ensure_created=>true).text = value.to_s end |