Class: Blacklight::Facets::CountComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::Facets::CountComponent
- Defined in:
- app/components/blacklight/facets/count_component.rb
Overview
Display count of a facet value
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hits:, classes:) ⇒ CountComponent
constructor
A new instance of CountComponent.
- #render? ⇒ Boolean
Methods inherited from Component
reset_compiler!, sidecar_files, upstream_sidecar_files
Constructor Details
#initialize(hits:, classes:) ⇒ CountComponent
Returns a new instance of CountComponent.
7 8 9 10 |
# File 'app/components/blacklight/facets/count_component.rb', line 7 def initialize(hits:, classes:) @hits = hits @classes = classes end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
12 13 14 |
# File 'app/components/blacklight/facets/count_component.rb', line 12 def classes @classes end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
12 13 14 |
# File 'app/components/blacklight/facets/count_component.rb', line 12 def hits @hits end |
Instance Method Details
#call ⇒ Object
18 19 20 |
# File 'app/components/blacklight/facets/count_component.rb', line 18 def call tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(hits)), class: classes) end |
#render? ⇒ Boolean
14 15 16 |
# File 'app/components/blacklight/facets/count_component.rb', line 14 def render? hits.present? end |