Class: Rufus::Tokyo::TableResultSet
Included Modules
Enumerable
The thing queries return
Constructor Summary
public
initialize(table, list_pointer, query_opts)
[View source]
868 869 870 871 872 873 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 868 def initialize (table, list_pointer, query_opts) @table = table @list = Rufus::Tokyo::List.new(list_pointer) @opts = query_opts end |
Public Visibility
Public Instance Method Summary
| #each |
The classical each. |
|---|---|
| #free #close #destroy |
Frees this query (the underlying Tokyo Cabinet list structure). |
| #size #length |
Returns the count of element in this result set. |
| #to_a |
Returns an array of hashes. |
Public Instance Method Details
each
public
each
The classical each
[View source]
886 887 888 889 890 891 892 893 894 895 896 897 898 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 886 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
public
free
Also known as: close destroy
Frees this query (the underlying Tokyo Cabinet list structure)
[View source]
909 910 911 912 913 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 909 def free @list.free @list = nil end |
size
public
size
Also known as: length
Returns the count of element in this result set
[View source]
877 878 879 880 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 877 def size @list.size end |
to_a
public
to_a
Returns an array of hashes
[View source]
902 903 904 905 |
# File 'lib/rufus/tokyo/cabinet/table.rb', line 902 def to_a collect { |m| m } end |