class EOAT::Result::EveType::Result
Parser class of of EVE API xml. Has the structure of the xml root. Starting from [‘eveapi’] @example
eve = EOAT::Result::EveType::Result.new(xml_to_hash) eve.from_cache #=> false
@attribute from_cache
[FalseClass, TrueClass] Return ‘true` if data from cache @attribute cached_until
[Time] Return `cachedUntil` as time @attribute request_time
[Time] Alias to xml `currentTime` as time @attribute result [Array] List of children
Attributes
cached_until[R]
from_cache[RW]
request_time[R]
result[R]
Public Class Methods
new(hash)
click to toggle source
@param [Hash] hash the xml body parsed to hash
# File lib/eoat/result/eve_type.rb, line 26 def initialize(hash) hash = hash.key?('eveapi') ? hash['eveapi'] : EOAT::Exception::ParseError.new('Wrong parse data') @from_cache = false @cached_until = Time.parse(hash['cachedUntil'] + 'UTC') @request_time = Time.parse(hash['currentTime'] + 'UTC') @result = hash['result'].keys - Array.new(1, 'rowset') hash['result'].keys.each do |key| value = hash['result'][key] case value when Hash if value.key? 'row' var_name = value['name'] var_value = RowSet.new(value) @result << var_name else var_name = key var_value = Row.new(value) end self.instance_variable_set("@#{var_name}", var_value) self.class.send( :define_method, var_name, proc{self.instance_variable_get("@#{var_name}")} ) when Array value.each do |v| self.instance_variable_set("@#{v['name']}", RowSet.new(v)) self.class.send( :define_method, v['name'], proc{self.instance_variable_get("@#{v['name']}")} ) @result << v['name'] end when String, NilClass self.instance_variable_set("@#{key}", value) self.class.send( :define_method, key, proc{self.instance_variable_get("@#{key}")} ) else raise EOAT::Exception::ParseError.new "Unable to parse the the value of #{value}" end end end
Public Instance Methods
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/eoat/result/eve_type.rb, line 73 def method_missing(meth, *args, &block) if instance_variable_defined?("@#{meth.to_s}") instance_variable_get("@#{meth.to_s}") else super end end
respond_to?(meth)
click to toggle source
Calls superclass method
# File lib/eoat/result/eve_type.rb, line 81 def respond_to?(meth) if instance_variable_defined?("@#{meth.to_s}") true else super end end