Class: Jylis::DataType::TLOG::Result
- Inherits:
-
Object
- Object
- Jylis::DataType::TLOG::Result
- Includes:
- Enumerable
- Defined in:
- lib/jylis-rb/data_types/tlog.rb
Overview
The result of a TLOG query.
Class Method Summary collapse
-
.parse(query_result) ⇒ Jylis::DataType::TLOG::Result
Construct a Result from a raw query result.
Instance Method Summary collapse
-
#[](index) ⇒ Jylis::DataType::TLOG::Row
The row at the given index.
-
#count ⇒ Integer
Number of rows.
-
#each(&block) ⇒ Object
:no doc:.
-
#initialize(rows) ⇒ Result
constructor
A new instance of Result.
-
#to_a ⇒ Object
Reconstruct the raw result returned by the database.
Constructor Details
#initialize(rows) ⇒ Result
Returns a new instance of Result.
25 26 27 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 25 def initialize(rows) @rows = rows end |
Class Method Details
.parse(query_result) ⇒ Jylis::DataType::TLOG::Result
Construct a Result from a raw query result.
16 17 18 19 20 21 22 23 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 16 def self.parse(query_result) rows = query_result.reduce([]) do |memo, row| memo << Row.parse(row) memo end new(rows) end |
Instance Method Details
#[](index) ⇒ Jylis::DataType::TLOG::Row
Returns the row at the given index.
30 31 32 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 30 def [](index) @rows[index] end |
#count ⇒ Integer
Returns number of rows.
40 41 42 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 40 def count @rows.count end |
#each(&block) ⇒ Object
:no doc:
35 36 37 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 35 def each(&block) @rows.each(&block) end |
#to_a ⇒ Object
Reconstruct the raw result returned by the database.
45 46 47 |
# File 'lib/jylis-rb/data_types/tlog.rb', line 45 def to_a @rows.map(&:to_a) end |