Class: Blacklight::Hierarchy::FacetGroup
- Inherits:
-
Object
- Object
- Blacklight::Hierarchy::FacetGroup
- Includes:
- Enumerable
- Defined in:
- lib/blacklight/hierarchy/hierarchical_facet.rb
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
readonly
Returns the value of attribute delimiter.
-
#facet_data ⇒ Object
readonly
Returns the value of attribute facet_data.
-
#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(&block) ⇒ Object
- #each_pair ⇒ Object
- #facets(prefix = nil) ⇒ Object
-
#initialize(facet_data, delimiter = ':') ⇒ FacetGroup
constructor
A new instance of FacetGroup.
- #keys(prefix = nil) ⇒ Object
Constructor Details
#initialize(facet_data, delimiter = ':') ⇒ FacetGroup
Returns a new instance of FacetGroup.
41 42 43 44 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 41 def initialize(facet_data, delimiter = ':') @facet_data = Hash[*facet_data] @delimiter = delimiter end |
Instance Attribute Details
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
38 39 40 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 38 def delimiter @delimiter end |
#facet_data ⇒ Object (readonly)
Returns the value of attribute facet_data.
38 39 40 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 38 def facet_data @facet_data end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
38 39 40 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 38 def hits @hits end |
#qname ⇒ Object (readonly)
Returns the value of attribute qname.
38 39 40 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 38 def qname @qname end |
Instance Method Details
#[](value) ⇒ Object
70 71 72 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 70 def [](value) facets(value) end |
#each(&block) ⇒ Object
46 47 48 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 46 def each(&block) facets.each &block end |
#each_pair ⇒ Object
50 51 52 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 50 def each_pair facets.each { |f| yield f.name, f } end |
#facets(prefix = nil) ⇒ Object
66 67 68 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 66 def facets(prefix = nil) FacetItem.new(prefix.to_s, facet_data[prefix], self) end |
#keys(prefix = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/blacklight/hierarchy/hierarchical_facet.rb', line 54 def keys(prefix = nil) if prefix.nil? facet_data.collect { |k, _v| k.split(delimiter).first }.uniq else path = prefix.to_s.split(delimiter) facet_data.collect do |k, _v| facet_path = k.split(delimiter) facet_path[0..path.length - 1] == path ? facet_path[path.length] : nil end.compact.uniq end end |