# File lib/hwp_properties.rb, line 23 def initialize(xml, name) @name, @kind, @value, @unit = xml['name'], xml['kind'].to_sym, xml['value'], xml['unit'] declare_ranges(xml) self end
# File lib/hwp_properties.rb, line 29 def present? ! @value.nil? end
# File lib/hwp_properties.rb, line 35 def declare_ranges(xml) case xml['kind'] when 'range' then self.class.instance_eval do attr_reader :range end @range = { :from => xml.xpath('range').first['first'], :to => xml.xpath('range').first['last'] } when 'enum' then self.class.instance_eval do attr_reader :options end @options = xml.xpath('enum/entry').collect { |e| e['value'] } end end