Class: Rufus::Tokyo::TableResultSet
- Inherits:
-
Object
- Object
- Rufus::Tokyo::TableResultSet
- Includes:
- 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.
859 860 861 862 863 864 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 859 def initialize (table, list_pointer, query_opts) @table = table @list = Rufus::Tokyo::List.new(list_pointer) @opts = query_opts end |
Instance Method Details
#each ⇒ Object
The classical each
877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 877 def each (0..size-1).each do |i| pk = @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)
900 901 902 903 904 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 900 def free @list.free @list = nil end |
#size ⇒ Object Also known as: length
Returns the count of element in this result set
868 869 870 871 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 868 def size @list.size end |
#to_a ⇒ Object
Returns an array of hashes
893 894 895 896 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 893 def to_a collect { |m| m } end |