class EOAT::Result::EveType::RowSet
Rowset container for xml data. Usually not called directly @attribute key [String] The value of key for indexing @attribute columns [Array] The array of methods names for Row
class @attribute name [String] The name of rowset @attribute entries [Array] The array of Row
objects
Attributes
columns[RW]
entries[RW]
entries_index[RW]
key[RW]
Public Class Methods
new(hash)
click to toggle source
@param [Hash] hash the roset value from xml as hash
# File lib/eoat/result/eve_type.rb, line 100 def initialize(hash) @key = hash['key'] @columns = hash['columns'].split(',') @name = hash['name'] if hash.key? 'row' case hash['row'] when Array @entries = Array.new(hash['row'].map.each {|row| Row.new(row)}) when Hash @entries = Array.new(1, Row.new(hash['row'])) else raise EOAT::Exception::ParseError.new "Unable to parse the the value of #{hash['row']}" end else @entries = Array.new end @entries_index = Hash.new if @key @entries.each_with_index do |record, i| key = record.public_send(@key).to_i if @entries_index.key? key case @entries_index[key] when Array @entries_index[key] << i when Fixnum, Integer @entries_index[key] = [@entries_index[key], i] else # nothing end else @entries_index[key] = i end end end end
Public Instance Methods
get(key)
click to toggle source
Get method for entries. Used attribute ‘key` for indexing. Return first fount Row
. @param [Integer, String] key the value that been search
# File lib/eoat/result/eve_type.rb, line 139 def get(key) index = @entries_index[key.to_i] if index case index when Array return @entries.values_at(*index) else return @entries[index] end end nil end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/eoat/result/eve_type.rb, line 152 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 160 def respond_to?(meth) if instance_variable_defined?("@#{meth.to_s}") true else super end end