Class: ThinkingSphinx::Masks::GroupEnumeratorsMask

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/masks/group_enumerators_mask.rb

Instance Method Summary collapse

Constructor Details

#initialize(search) ⇒ GroupEnumeratorsMask



2
3
4
# File 'lib/thinking_sphinx/masks/group_enumerators_mask.rb', line 2

def initialize(search)
  @search = search
end

Instance Method Details

#can_handle?(method) ⇒ Boolean



6
7
8
# File 'lib/thinking_sphinx/masks/group_enumerators_mask.rb', line 6

def can_handle?(method)
  public_methods(false).include?(method)
end

#each_with_count(&block) ⇒ Object



10
11
12
13
14
# File 'lib/thinking_sphinx/masks/group_enumerators_mask.rb', line 10

def each_with_count(&block)
  @search.raw.each_with_index do |row, index|
    yield @search[index], row['@count']
  end
end

#each_with_group(&block) ⇒ Object



16
17
18
19
20
# File 'lib/thinking_sphinx/masks/group_enumerators_mask.rb', line 16

def each_with_group(&block)
  @search.raw.each_with_index do |row, index|
    yield @search[index], row['@groupby']
  end
end

#each_with_group_and_count(&block) ⇒ Object



22
23
24
25
26
# File 'lib/thinking_sphinx/masks/group_enumerators_mask.rb', line 22

def each_with_group_and_count(&block)
  @search.raw.each_with_index do |row, index|
    yield @search[index], row['@groupby'], row['@count']
  end
end