Class: Xapit::Client::FacetOption

Inherits:
Object
  • Object
show all
Defined in:
lib/xapit/client/facet_option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, option, applied_facets = []) ⇒ FacetOption

Returns a new instance of FacetOption.



5
6
7
8
9
10
# File 'lib/xapit/client/facet_option.rb', line 5

def initialize(attribute, option, applied_facets = [])
  @attribute = attribute
  @value = option[:value]
  @count = option[:count].to_i
  @applied_facets = applied_facets
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



4
5
6
# File 'lib/xapit/client/facet_option.rb', line 4

def attribute
  @attribute
end

#countObject (readonly)

Returns the value of attribute count.



4
5
6
# File 'lib/xapit/client/facet_option.rb', line 4

def count
  @count
end

Instance Method Details

#identifierObject



12
13
14
# File 'lib/xapit/client/facet_option.rb', line 12

def identifier
  Xapit.facet_identifier(@attribute, @value)
end

#nameObject



16
17
18
# File 'lib/xapit/client/facet_option.rb', line 16

def name
  @value
end

#to_paramObject



20
21
22
23
24
25
26
# File 'lib/xapit/client/facet_option.rb', line 20

def to_param
  if @applied_facets.include? identifier
    (@applied_facets - [identifier]).join('-')
  else
    (@applied_facets + [identifier]).join("-")
  end
end