Class: Stanford::Mods::Imprint
- Inherits:
-
Object
- Object
- Stanford::Mods::Imprint
- Defined in:
- lib/stanford-mods/imprint.rb
Overview
Get the imprint information from originInfo elements (and sub elements) to create display strings
This code is adapted from the mods_display gem. In a perfect world, this code would make use of the date_parsing class instead of reimplementing pieces of it; however, the date_parsing class only does years, and this does finer tuned dates and also reformats them according to the encoding.
Defined Under Namespace
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
Instance Method Summary collapse
-
#dates(date_field_keys = [:dateIssued, :dateCreated, :dateCaptured, :copyrightDate]) ⇒ Object
array of parsed but unformattted date values, for a given list of elements to pull data from.
-
#display_str ⇒ String
An imprint statement from a single originInfo element.
- #imprint_statements ⇒ Object
-
#initialize(element) ⇒ Imprint
constructor
A new instance of Imprint.
Constructor Details
#initialize(element) ⇒ Imprint
Returns a new instance of Imprint.
16 17 18 |
# File 'lib/stanford-mods/imprint.rb', line 16 def initialize(element) @element = element end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
13 14 15 |
# File 'lib/stanford-mods/imprint.rb', line 13 def element @element end |
Instance Method Details
#dates(date_field_keys = [:dateIssued, :dateCreated, :dateCaptured, :copyrightDate]) ⇒ Object
array of parsed but unformattted date values, for a given list of elements to pull data from
40 41 42 43 44 45 46 47 |
# File 'lib/stanford-mods/imprint.rb', line 40 def dates(date_field_keys = [:dateIssued, :dateCreated, :dateCaptured, :copyrightDate]) date_field_keys.map do |date_field| next unless element.respond_to?(date_field) date_elements = element.send(date_field) parse_dates(date_elements) if date_elements.present? end.compact.flatten end |
#display_str ⇒ String
Returns an imprint statement from a single originInfo element.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stanford-mods/imprint.rb', line 25 def display_str edition = edition_vals_str place = place_vals_str publisher = publisher_vals_str dates = date_str place_pub = compact_and_join_with_delimiter([place, publisher], ' : ') edition_place_pub = compact_and_join_with_delimiter([edition, place_pub], ' - ') ed_place_pub_dates = compact_and_join_with_delimiter([edition_place_pub, dates], ', ') ed_place_pub_dates end |
#imprint_statements ⇒ Object
20 21 22 |
# File 'lib/stanford-mods/imprint.rb', line 20 def imprint_statements display_str end |