Class: Blacklight::Facets::CountComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/facets/count_component.rb

Overview

Display count of a facet value

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#classesObject (readonly)

Returns the value of attribute classes.



12
13
14
# File 'app/components/blacklight/facets/count_component.rb', line 12

def classes
  @classes
end

#hitsObject (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

#callObject



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

Returns:

  • (Boolean)


14
15
16
# File 'app/components/blacklight/facets/count_component.rb', line 14

def render?
  hits.present?
end