module IsoDoc::IHO::BaseConvert
Public Instance Methods
error_parse(node, out)
click to toggle source
terms not defined in standoc
Calls superclass method
# File lib/isodoc/iho/base_convert.rb, line 5 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end
extract_edition(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 68 def extract_edition(bib) bib&.at(ns("./edition"))&.text end
extract_person_name(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 99 def extract_person_name(bib) p = bib.at(ns("./person/name")) or return c = p.at(ns("./completename")) and return c.text s = p&.at(ns("./surname"))&.text or return i = p.xpath(ns("./initial")) and front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join("") i.empty? and f = p.xpath(ns("./forename")) and front = f.map { |e| e.text[0].upcase }.join("") front ? "#{s} #{front}" : s end
extract_publisher(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 41 def extract_publisher(bib) c = bib .xpath(ns("./contributor[role/@type = 'publisher'][organization]")) abbrs = [] names = [] c&.each do |c1| n = c1.at(ns("./organization/name")) or next abbrs << (c1.at(ns("./organization/abbreviation")) || n) names << nodes_to_span(n) end return [nil, nil] if names.empty? [multiplenames_and(names), abbrs.map(&:text).join("/")] end
extract_uri(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 72 def extract_uri(bib) bib.at(ns("./uri")) end
iho?(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 110 def iho?(bib) extract_publisher(bib)[1] == "IHO" end
info(isoxml, out)
click to toggle source
Calls superclass method
# File lib/isodoc/iho/base_convert.rb, line 13 def info(isoxml, out) @meta.series isoxml, out super end
inline_bibitem_ref_code(bib)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 56 def inline_bibitem_ref_code(bib) id = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\ "@type = 'metanorma' or @type = 'ISSN' or "\ "@type = 'ISBN' or @type = 'rfc-anchor')]")) id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma')]")) return [nil, id, nil] if id id = Nokogiri::XML::Node.new("docidentifier", bib.document) id << "(NO ID)" [nil, id, nil] end
multiplenames_and(names)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 33 def multiplenames_and(names) return "" if names.empty? return names[0] if names.length == 1 return "#{names[0]} and #{names[1]}" if names.length == 2 names[0..-2].join(", ") + " and #{names[-1]}" end
nodes_to_span(node)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 25 def nodes_to_span(node) noko do |xml| xml.span do |s| node&.children&.each { |x| parse(x, s) } end end.join("") end
omit_docid_prefix(prefix)
click to toggle source
Calls superclass method
# File lib/isodoc/iho/base_convert.rb, line 76 def omit_docid_prefix(prefix) return true if prefix == "IHO" super end
render_identifier(id)
click to toggle source
Calls superclass method
# File lib/isodoc/iho/base_convert.rb, line 82 def render_identifier(id) if !id[1].nil? && (id[1]["type"] == "IHO") id[1].children = id[1].text.sub(/^IHO /, "") end super end
standard_citation(out, bib)
click to toggle source
- {number}
-
{docID} edition {edition}: {title}, {author/organization}
# File lib/isodoc/iho/base_convert.rb, line 115 def standard_citation(out, bib) if ftitle = bib.at(ns("./formattedref")) ftitle&.children&.each { |n| parse(n, out) } else id = render_identifier(inline_bibitem_ref_code(bib)) out << id[1] if id[1] ed = extract_edition(bib) if iho?(bib) out << " edition #{ed}" if ed out << ": " if id[1] || ed iso_title(bib)&.children&.each { |n| parse(n, out) } out << ", " author = extract_author(bib) out << author u = extract_uri(bib) out << " (<a href='#{u.text}'>#{u.text}</a>)" if u end end
std_bibitem_entry(list, bib, ordinal, biblio)
click to toggle source
# File lib/isodoc/iho/base_convert.rb, line 18 def std_bibitem_entry(list, bib, ordinal, biblio) list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref| prefix_bracketed_ref(ref, "[#{ordinal}]") standard_citation(ref, bib) end end