Class: Eve::API::Response::Row
- Inherits:
-
Object
- Object
- Eve::API::Response::Row
- Includes:
- Result
- Defined in:
- lib/eve/api/response/row.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#rowsets ⇒ Object
readonly
Returns the value of attribute rowsets.
Instance Method Summary collapse
-
#initialize(row, columns = row.attribute_nodes.collect { |c| c.name }) ⇒ Row
constructor
A new instance of Row.
- #inspect ⇒ Object
Methods included from Result
#[], #all_fields, #delegate_to_child, #delegate_to_rowset, #literal_value_for, #parse_children, #to_hash, #to_yaml
Constructor Details
#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 |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
3 4 5 |
# File 'lib/eve/api/response/row.rb', line 3 def fields @fields end |
#rowsets ⇒ Object (readonly)
Returns the value of attribute rowsets.
4 5 6 |
# File 'lib/eve/api/response/row.rb', line 4 def rowsets @rowsets end |
Instance Method Details
#inspect ⇒ Object
36 37 38 39 40 41 |
# File 'lib/eve/api/response/row.rb', line 36 def inspect "<Row " + fields.map do |field_name| "#{field_name}: #{send field_name}" end.join(', ') + ">" end |