Class: Blacklight::Document::CitationComponent

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

Overview

Render citations for the document

Constant Summary collapse

DEFAULT_FORMATS =
{
  'blacklight.citation.mla': :export_as_mla_citation_txt,
  'blacklight.citation.apa': :export_as_apa_citation_txt,
  'blacklight.citation.chicago': :export_as_chicago_citation_txt
}.freeze

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(document:, formats: DEFAULT_FORMATS) ⇒ CitationComponent

Returns a new instance of CitationComponent.

Parameters:

  • document (Blacklight::Document)
  • formats (Hash<String => Symbol>) (defaults to: DEFAULT_FORMATS)

    map of citation format names (suspiciously, i18n keys for them) to document methods that return the formatted citation.



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

def initialize(document:, formats: DEFAULT_FORMATS)
  @document = document
  @formats = formats.select { |_k, v| @document.respond_to?(v) }
end

Instance Method Details

#presenterObject



28
29
30
# File 'app/components/blacklight/document/citation_component.rb', line 28

def presenter
  helpers.document_presenter(@document)
end

#titleString

Returns:

  • (String)


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

def title
  presenter.heading
end