Class: EOAT::Result::EveType::RowSet

Inherits:
Object
  • Object
show all
Defined in:
lib/eoat/result/eve_type.rb

Overview

Rowset container for xml data. Usually not called directly

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ RowSet

Returns a new instance of RowSet.

Parameters:

  • hash (Hash)

    the roset value from xml as hash



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

#columnsObject

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

#entriesObject

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

#keyObject

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

#nameObject (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.

Parameters:

  • key (Integer, String)

    the value that been search



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