Class: Rufus::Tokyo::TableResultSet
- Inherits:
-
Object
- Object
- Rufus::Tokyo::TableResultSet
- Includes:
- CabinetLibMixin, Enumerable
- Defined in:
- lib/rufus/tokyo/cabinet/table.rb
Overview
The thing queries return
Instance Method Summary collapse
-
#each ⇒ Object
The classical each.
-
#free ⇒ Object
(also: #close, #destroy)
Frees this query (the underlying Tokyo Cabinet list structure).
-
#initialize(table, list_pointer, query_opts) ⇒ TableResultSet
constructor
A new instance of TableResultSet.
-
#size ⇒ Object
(also: #length)
Returns the count of element in this result set.
-
#to_a ⇒ Object
Returns an array of hashes.
Constructor Details
#initialize(table, list_pointer, query_opts) ⇒ TableResultSet
Returns a new instance of TableResultSet.
492 493 494 495 496 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 492 def initialize (table, list_pointer, query_opts) @table = table @list = list_pointer @opts = query_opts end |
Instance Method Details
#each ⇒ Object
The classical each
510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 510 def each (0..size-1).each do |i| pk = lib.tclistval2(@list, i) if @opts[:pk_only] yield(pk) else val = @table[pk] val[:pk] = pk unless @opts[:no_pk] yield(val) end end end |
#free ⇒ Object Also known as: close, destroy
Frees this query (the underlying Tokyo Cabinet list structure)
533 534 535 536 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 533 def free lib.tclistdel(@list) @list = nil end |
#size ⇒ Object Also known as: length
Returns the count of element in this result set
501 502 503 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 501 def size lib.tclistnum(@list) end |
#to_a ⇒ Object
Returns an array of hashes
526 527 528 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 526 def to_a collect { |m| m } end |