Sha256: c5ba4ab480fd4fea9e694263dd8bb49630bbf8677d3f2506b080a79f17ef6a51

Contents?: true

Size: 1008 Bytes

Versions: 8

Compression:

Stored size: 1008 Bytes

Contents

module Groonga
  class Database
    def each
      context = Context.instance
      flags =
        TableCursorFlags::ASCENDING |
        TableCursorFlags::BY_ID
      TableCursor.open(self, :flags => flags) do |cursor|
        cursor.each do |id|
          object = context[id]
          yield(object) if object
        end
      end
    end

    def each_table(options={})
      context = Context.instance
      min = options[:prefix]
      flags = 0
      if options[:order] == :descending
        flags |= TableCursorFlags::DESCENDING
      else
        flags |= TableCursorFlags::ASCENDING
      end
      if options[:order_by] == :id
        flags |= TableCursorFlags::BY_ID
      else
        flags |= TableCursorFlags::BY_KEY
      end
      flags |= TableCursorFlags::PREFIX if min
      TableCursor.open(self, :min => min, :flags => flags) do |cursor|
        cursor.each do |id|
          object = context[id]
          yield(object) if object.is_a?(Table)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rroonga-5.0.4-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.4-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.3-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.3-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.1-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.1-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb