Class: Hyrax::CitationsBehaviors::Formatters::OpenUrlFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Hyrax::CitationsBehaviors::Formatters::OpenUrlFormatter
- Defined in:
- app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
Constant Summary collapse
- FIELD_MAP =
{ title: 'title', creator: 'creator', subject: 'subject', description: 'description', publisher: 'publisher', contributor: 'contributor', date_created: 'date', resource_type: 'format', identifier: 'identifier', language: 'language', keyword: 'relation', based_near: 'coverage', license: 'license' }.freeze
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from BaseFormatter
Methods included from NameBehavior
#abbreviate_name, #all_authors, #author_list, #given_name_first, #surname_first
Methods included from CommonBehavior
#clean_end_punctuation, #persistent_url
Constructor Details
This class inherits a constructor from Hyrax::CitationsBehaviors::Formatters::BaseFormatter
Instance Method Details
#format(work) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb', line 5 def format(work) export_text = [] export_text << "url_ver=Z39.88-2004&ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator" FIELD_MAP.each do |element, kev| next unless work.respond_to?(element) values = work.send(element) Array.wrap(values).each do |value| next if value.blank? export_text << "rft.#{kev}=#{CGI.escape(value.to_s)}" end end export_text.join('&') if export_text.present? end |