Class: EOAT::Result::EveType::RowSet
- Inherits:
-
Object
- Object
- EOAT::Result::EveType::RowSet
- Defined in:
- lib/eoat/result/eve_type.rb
Overview
Rowset container for xml data. Usually not called directly
Instance Attribute Summary collapse
-
#columns ⇒ Object
The array of methods names for Row class.
-
#entries ⇒ Object
The array of Row objects.
-
#key ⇒ Object
The value of key for indexing.
-
#name ⇒ Object
readonly
The name of rowset.
Instance Method Summary collapse
-
#get(key) ⇒ Object
Get method for entries.
-
#initialize(hash) ⇒ RowSet
constructor
A new instance of RowSet.
Constructor Details
#initialize(hash) ⇒ RowSet
Returns a new instance of RowSet.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/eoat/result/eve_type.rb', line 84 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 end |
Instance Attribute Details
#columns ⇒ Object
The array of methods names for Row class
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/eoat/result/eve_type.rb', line 80 class RowSet attr_accessor :key, :columns, :entries # @param [Hash] hash the roset value from xml as hash 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 end # TODO: Correct method. Eliminate return of only the first result. # Get method for entries. Used attribute `key` for indexing. # Return first fount Row. # @param [Integer, String] key the value that been search def get(key) @entries.at(@entries.index {|x| x.send(@key) == key.to_s}) end end |
#entries ⇒ Object
The array of Row objects
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/eoat/result/eve_type.rb', line 80 class RowSet attr_accessor :key, :columns, :entries # @param [Hash] hash the roset value from xml as hash 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 end # TODO: Correct method. Eliminate return of only the first result. # Get method for entries. Used attribute `key` for indexing. # Return first fount Row. # @param [Integer, String] key the value that been search def get(key) @entries.at(@entries.index {|x| x.send(@key) == key.to_s}) end end |
#key ⇒ Object
The value of key for indexing
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/eoat/result/eve_type.rb', line 80 class RowSet attr_accessor :key, :columns, :entries # @param [Hash] hash the roset value from xml as hash 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 end # TODO: Correct method. Eliminate return of only the first result. # Get method for entries. Used attribute `key` for indexing. # Return first fount Row. # @param [Integer, String] key the value that been search def get(key) @entries.at(@entries.index {|x| x.send(@key) == key.to_s}) end end |
#name ⇒ Object (readonly)
The name of rowset
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/eoat/result/eve_type.rb', line 80 class RowSet attr_accessor :key, :columns, :entries # @param [Hash] hash the roset value from xml as hash 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 end # TODO: Correct method. Eliminate return of only the first result. # Get method for entries. Used attribute `key` for indexing. # Return first fount Row. # @param [Integer, String] key the value that been search def get(key) @entries.at(@entries.index {|x| x.send(@key) == key.to_s}) end end |
Instance Method Details
#get(key) ⇒ Object
Get method for entries. Used attribute key for indexing.
Return first fount Row.
107 108 109 |
# File 'lib/eoat/result/eve_type.rb', line 107 def get(key) @entries.at(@entries.index {|x| x.send(@key) == key.to_s}) end |