Method: Eve::API::Response::Row#initialize
- Defined in:
- lib/eve/api/response/row.rb
#initialize(row, columns = row.attribute_nodes.collect { |c| c.name }) ⇒ Row
Returns a new instance of Row.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/eve/api/response/row.rb', line 6 def initialize(row, columns = row.attribute_nodes.collect { |c| c.name }) @rowsets = [] # @fields = row.attributes.keys.collect { |f| f.underscore } @fields = columns.collect { |c| c.underscore } # pre-emptively define all known columns to return nil klass = (class << self; self; end) columns.each { |c| klass.send(:define_method, c.underscore) { nil } } row.attribute_nodes.each_with_index do |attr, i| name = columns[i] if name.nil? name = attr.name @fields << name.underscore end value = literal_value_for attr.value klass.module_eval do define_method name.underscore do value end alias_method name, name.underscore end end parse_children row end |