Class: ModsDisplay::RelatedItem::ValueRenderer
- Inherits:
-
Object
- Object
- ModsDisplay::RelatedItem::ValueRenderer
- Defined in:
- lib/mods_display/fields/related_item.rb
Overview
this class provides html markup and is mimicking the same class
in NestedRelatedItem (which is subclassed in purl application)
Instance Method Summary collapse
-
#initialize(related_item_element) ⇒ ValueRenderer
constructor
A new instance of ValueRenderer.
- #render ⇒ Object
Constructor Details
#initialize(related_item_element) ⇒ ValueRenderer
Returns a new instance of ValueRenderer.
31 32 33 |
# File 'lib/mods_display/fields/related_item.rb', line 31 def initialize() @related_item_element = end |
Instance Method Details
#render ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mods_display/fields/related_item.rb', line 35 def render if .location? element_text(.location_nodeset) elsif .reference? reference_title() elsif .titleInfo_nodeset.any? title = element_text(.titleInfo_nodeset) location = nil location = element_text(.location_url_nodeset) if .location_url_nodeset.length.positive? return if title.empty? if location "<a href='#{location}'>#{title}</a>".html_safe else title end elsif .note_nodeset.any? citation = .note_nodeset.find { |note| note['type'] == 'preferred citation' } element_text(citation) if citation end end |