Sha256: 0106773b92d23098b7cc49ed7a3663e3a7f1e8878bcfcc16db01305ff04e1124

Contents?: true

Size: 1.15 KB

Versions: 18

Compression:

Stored size: 1.15 KB

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_name(options={})
      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|
          name = cursor.key
          yield(name)
        end
      end
    end

    def each_table(options={})
      context = Context.instance
      each_name(options) do |name|
        next if name.include?(".")
        object = context[name]
        yield(object) if object.is_a?(Table)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rroonga-6.0.7-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.7-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.5-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.5-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.4-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.4-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.0-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-6.0.0-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.1.1-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.1.1-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.9-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.9-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.8-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.8-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.5-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb
rroonga-5.0.5-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/database.rb