Sha256: 63030f9f04941e30629a074c3ae8576042e9a690507083aa0baf220405a18514

Contents?: true

Size: 805 Bytes

Versions: 7

Compression:

Stored size: 805 Bytes

Contents

require "yaml"

module RelatonGb
  class HashConverter < RelatonIsoBib::HashConverter
    class << self
      # @override RelatonBib::HashConverter.hash_to_bib
      # @param args [Hash]
      # @param nested [TrueClass, FalseClass]
      # @return [Hash]
      def hash_to_bib(args)
        ret = super
        return if ret.nil?

        ccs_hash_to_bib(ret)
        ret
      end

      private

      #
      # Ovverides superclass's method
      #
      # @param item [Hash]
      # @retirn [RelatonGb::GbBibliographicItem]
      def bib_item(item)
        GbBibliographicItem.new(item)
      end

      def ccs_hash_to_bib(ret)
        ret[:ccs] = RelatonBib.array(ret[:ccs]).map do |ccs|
          (ccs[:code] && Cnccs.fetch(ccs[:code])) || Cnccs.fetch(ccs)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
relaton-gb-1.16.3 lib/relaton_gb/hash_converter.rb
relaton-gb-1.16.2 lib/relaton_gb/hash_converter.rb
relaton-gb-1.16.1 lib/relaton_gb/hash_converter.rb
relaton-gb-1.16.0 lib/relaton_gb/hash_converter.rb
relaton-gb-1.14.0 lib/relaton_gb/hash_converter.rb
relaton-gb-1.13.0 lib/relaton_gb/hash_converter.rb
relaton-gb-1.12.1 lib/relaton_gb/hash_converter.rb