Class: Blacklight::Hierarchy::FacetItem
- Inherits:
-
Object
- Object
- Blacklight::Hierarchy::FacetItem
- Defined in:
- lib/blacklight/hierarchy/hierarchical_facet.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#qname ⇒ Object
readonly
Returns the value of attribute qname.
Instance Method Summary collapse
- #[](value) ⇒ Object
- #each_pair ⇒ Object
-
#initialize(qname, hits, facet) ⇒ FacetItem
constructor
A new instance of FacetItem.
- #inspect ⇒ Object
- #keys ⇒ Object
- #name ⇒ Object
- #path ⇒ Object
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
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
4 5 6 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 4 def hits @hits end |
#qname ⇒ Object (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_pair ⇒ Object
16 17 18 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 16 def each_pair keys.each { |k| yield k, self[k] } end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 32 def inspect "#<#{self.class.name}:#{name}=>#{hits.inspect} (#{keys.join ', '})>" end |
#keys ⇒ Object
20 21 22 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 20 def keys @facet.keys(qname) end |
#name ⇒ Object
28 29 30 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 28 def name @qname.split(@facet.delimiter).last end |
#path ⇒ Object
24 25 26 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 24 def path @qname.split(@facet.delimiter)[0..-2] end |