Class: Blacklight::Document::ThumbnailComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/document/thumbnail_component.rb

Overview

Render the thumbnail for the document

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(counter:, presenter: nil, image_options: {}) ⇒ ThumbnailComponent

Returns a new instance of ThumbnailComponent.

Parameters:

  • presenter (Blacklight::DocumentPresenter) (defaults to: nil)
  • counter (Integer)
  • image_options (Hash) (defaults to: {})

    options for the thumbnail presenter’s image tag



12
13
14
15
16
# File 'app/components/blacklight/document/thumbnail_component.rb', line 12

def initialize(counter:, presenter: nil, image_options: {})
  @presenter = presenter
  @counter = counter
  @image_options = { alt: '' }.merge(image_options)
end

Instance Attribute Details

#presenterObject

Returns the value of attribute presenter.



18
19
20
# File 'app/components/blacklight/document/thumbnail_component.rb', line 18

def presenter
  @presenter
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/components/blacklight/document/thumbnail_component.rb', line 24

def render?
  presenter.thumbnail && thumbnail_value
end

#thumbnail_valueObject



20
21
22
# File 'app/components/blacklight/document/thumbnail_component.rb', line 20

def thumbnail_value
  @thumbnail_value ||= presenter.thumbnail.render(@image_options)
end