class RelatonBipm::HashConverter
Public Class Methods
hash_to_bib(args, nested = false)
click to toggle source
@override RelatonIsoBib::HashConverter.hash_to_bib @param args [Hash] @param nested [TrueClass, FalseClass] @return [Hash]
Calls superclass method
# File lib/relaton_bipm/hash_converter.rb, line 12 def hash_to_bib(args, nested = false) ret = super return if ret.nil? # project_group_hash_to_bib ret commentperiod_hash_to_bib ret ret end
Private Class Methods
acronyms()
click to toggle source
# File lib/relaton_bipm/hash_converter.rb, line 93 def acronyms @@acronyms ||= YAML.load_file File.join __dir__, "acronyms.yaml" end
bib_item(item_hash)
click to toggle source
@param item_hash [Hash] @return [RelatonBib::BibliographicItem]
# File lib/relaton_bipm/hash_converter.rb, line 25 def bib_item(item_hash) BipmBibliographicItem.new(**item_hash) end
commentperiod_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
# File lib/relaton_bipm/hash_converter.rb, line 42 def commentperiod_hash_to_bib(ret) ret[:comment_period] &&= CommentPeriond.new(**ret[:comment_period]) end
committee_variants(cmt)
click to toggle source
# File lib/relaton_bipm/hash_converter.rb, line 86 def committee_variants(cmt) array(cmt[:variants]).each_with_object([]) do |v, a| c = v[:content] || (ac = acronyms[cmt[:acronym]]) && ac[v[:language]] a << RelatonBib::LocalizedString.new(c, v[:language], v[:script]) if c end end
dates_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
Calls superclass method
# File lib/relaton_bipm/hash_converter.rb, line 55 def dates_hash_to_bib(ret) super ret[:date] &&= ret[:date].map { |d| BibliographicDate.new(**d) } end
editorialgroup_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
# File lib/relaton_bipm/hash_converter.rb, line 69 def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength return unless ret[:editorialgroup] cmt = ret[:editorialgroup][:committee].map do |c| if (vars = committee_variants c).any? content = RelatonBib::LocalizedString.new vars Committee.new acronym: c[:acronym], content: content else Committee.new(**c) end end wg = array(ret[:editorialgroup][:workgroup]).map do |w| w.is_a?(Hash) ? WorkGroup.new(**w) : WorkGroup.new(content: w) end ret[:editorialgroup] = EditorialGroup.new committee: cmt, workgroup: wg end
relations_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
Calls superclass method
# File lib/relaton_bipm/hash_converter.rb, line 61 def relations_hash_to_bib(ret) super ret[:relation] &&= ret[:relation].map do |r| RelatonBipm::DocumentRelation.new(**r) end end
structuredidentifier_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
# File lib/relaton_bipm/hash_converter.rb, line 98 def structuredidentifier_hash_to_bib(ret) ret[:structuredidentifier] &&= StructuredIdentifier.new( **ret[:structuredidentifier], ) end
title_hash_to_bib(ret)
click to toggle source
@param ret [Hash]
# File lib/relaton_bipm/hash_converter.rb, line 30 def title_hash_to_bib(ret) ret[:title] &&= array(ret[:title]) .reduce(RelatonBib::TypedTitleStringCollection.new) do |m, t| m << if t.is_a? Hash RelatonBib::TypedTitleString.new(**t) else RelatonBib::TypedTitleString.new(content: t) end end end