Class: Groonga::SubRecords

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/groonga/sub-records.rb

Overview

Represents sub records of a Record. Grouped result set by Table#group only has sub records.

SubRecords acts like an ::Array.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ SubRecords

Creates a sub records container for the record.

Normally, users don’t need to instantiate Groonga::SubRecords directly. Record#sub_records creates and returns a Groonga::SubRecords.

Parameters:

  • record (Record)

    The record that has this sub records.



36
37
38
# File 'lib/groonga/sub-records.rb', line 36

def initialize(record)
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

The record that has this sub records.



27
28
29
# File 'lib/groonga/sub-records.rb', line 27

def record
  @record
end

Instance Method Details

#[](index) ⇒ Record

Returns A sub record at index.

Parameters:

  • index (Integer)

    A 0-origin index.

Returns:

  • (Record)

    A sub record at index.



57
58
59
# File 'lib/groonga/sub-records.rb', line 57

def [](index)
  to_a[index]
end

#each {|record| ... } ⇒ void

This method returns an undefined value.

Yields:

  • (record)

    Gives a sub record to the block.

Yield Parameters:

  • record (Record)

    サブレコード。



43
44
45
# File 'lib/groonga/sub-records.rb', line 43

def each(&block)
  @record.table.each_sub_record(@record.record_raw_id, &block)
end

#to_aArray<Record> Also known as: to_ary

Returns Sub records as ::Array.

Returns:



48
49
50
# File 'lib/groonga/sub-records.rb', line 48

def to_a
  @sub_records ||= super
end