Class: Sunspot::FacetData::FieldFacetData

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sunspot/facet_data.rb

Direct Known Subclasses

DateFacetData

Instance Attribute Summary

Attributes inherited from Abstract

#field

Instance Method Summary collapse

Methods inherited from Abstract

#cast, #reference, #row_value

Constructor Details

#initialize(facet_values, field) ⇒ FieldFacetData

:nodoc:



26
27
28
# File 'lib/sunspot/facet_data.rb', line 26

def initialize(facet_values, field) #:nodoc:
  @facet_values, @field = facet_values, field
end

Instance Method Details

#nameObject

The name of the field that contains this facet’s values

Returns

Symbol

The field name



36
37
38
# File 'lib/sunspot/facet_data.rb', line 36

def name
  @field.name
end

#rowsObject

The rows returned for this facet.

Returns

Array

Collection of FacetRow objects, in the order returned by Solr



46
47
48
49
50
51
52
53
54
55
# File 'lib/sunspot/facet_data.rb', line 46

def rows
  @rows ||=
    begin
      rows = []
      @facet_values.each_slice(2) do |value, count|
        rows << yield(row_value(value), count)
      end
      rows
    end
end