class RelatonIho::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_iho/hash_converter.rb, line 8
def hash_to_bib(args, nested = false)
  ret = super
  return if ret.nil?

  commentperiod_hash_to_bib ret
  ret
end

Private Class Methods

bib_item(item_hash) click to toggle source

@param item_hash [Hash] @return [RelatonBib::BibliographicItem]

# File lib/relaton_iho/hash_converter.rb, line 20
def bib_item(item_hash)
  IhoBibliographicItem.new item_hash
end
commentperiod_hash_to_bib(ret) click to toggle source

@param ret [Hash]

# File lib/relaton_iho/hash_converter.rb, line 25
def commentperiod_hash_to_bib(ret)
  ret[:commentperiod] &&= CommentPeriond.new(**ret[:commentperiod])
end
editorialgroup_hash_to_bib(ret) click to toggle source

@param ret [Hash]

# File lib/relaton_iho/hash_converter.rb, line 30
def editorialgroup_hash_to_bib(ret)
  eg = ret[:editorialgroup]
  return unless eg.is_a?(Hash) || eg&.any?

  collection = array(eg).map do |g|
    EditorialGroup.new(array(g).map { |wg| iho_workgroup wg })
  end
  ret[:editorialgroup] = EditorialGroupCollection.new collection
end
iho_workgroup(ihowg) click to toggle source

@param ihowg [Hash] @return [RelatonIho::Committee, RelatonIho::Workgroup,

RelatonIho::Commission]
# File lib/relaton_iho/hash_converter.rb, line 43
def iho_workgroup(ihowg)
  key, value = ihowg&.first
  return unless key && value.is_a?(Hash)

  klass = Object.const_get "RelatonIho::#{key.capitalize}"
  subwg = value.select do |k, _|
    %i[committee workgroup commission].include? k
  end
  klass.new value[:abbreviation], value[:name], iho_workgroup(subwg)
end