Class: Blacklight::Hierarchy::FacetItem

Inherits:
Object
  • Object
show all
Defined in:
lib/blacklight/hierarchy/hierarchical_facet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(qname, hits, facet) ⇒ FacetItem

Returns a new instance of FacetItem.



6
7
8
9
10
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 6

def initialize(qname, hits, facet)
  @qname = qname
  @hits = hits
  @facet = facet
end

Instance Attribute Details

#hitsObject (readonly)

Returns the value of attribute hits.



4
5
6
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 4

def hits
  @hits
end

#qnameObject (readonly)

Returns the value of attribute qname.



4
5
6
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 4

def qname
  @qname
end

Instance Method Details

#[](value) ⇒ Object



12
13
14
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 12

def [](value)
  @facet.facets([qname, value].select(&:present?).join(@facet.delimiter))
end

#each_pairObject



16
17
18
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 16

def each_pair
  keys.each { |k| yield k, self[k] }
end

#inspectObject



32
33
34
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 32

def inspect
  "#<#{self.class.name}:#{name}=>#{hits.inspect} (#{keys.join ', '})>"
end

#keysObject



20
21
22
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 20

def keys
  @facet.keys(qname)
end

#nameObject



28
29
30
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 28

def name
  @qname.split(@facet.delimiter).last
end

#pathObject



24
25
26
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 24

def path
  @qname.split(@facet.delimiter)[0..-2]
end