Sha256: c774e8c370d275b74d6f2bb5e59cc5cbab722b9c719cf897b74b0fc8c58bb6dd
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require "stanford-mods/mappings" require "stanford-mods/version" require 'mods' # Stanford specific wranglings of MODS metadata as an extension of the Mods::Record object module Stanford module Mods class Record < ::Mods::Record # the first encountered <mods><name> element with marcrelator flavor role of 'Creator' or 'Author'. # if no marcrelator 'Creator' or 'Author', the first name without a role. # if no name without a role, then nil # @return [String] a name in the display_value_w_date form # see Mods::Record.name in nom_terminology for details on the display_value algorithm def main_author_w_date result = nil first_wo_role = nil @mods_ng_xml.plain_name.each { |n| if n.role.size == 0 first_wo_role ||= n end n.role.each { |r| if r.authority.include?('marcrelator') && (r.value.include?('Creator') || r.value.include?('Author')) result ||= n.display_value_w_date end } } if !result && first_wo_role result = first_wo_role.display_value_w_date end result end # main_author # all names, in display form, except the main_author # names will be the display_value_w_date form # see Mods::Record.name in nom_terminology for details on the display_value algorithm def additional_authors_w_dates results = [] @mods_ng_xml.plain_name.each { |n| results << n.display_value_w_date } results.delete(main_author_w_date) results end end # Record class end # Mods module end # Stanford module
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stanford-mods-0.0.6 | lib/stanford-mods.rb |
stanford-mods-0.0.5 | lib/stanford-mods.rb |