Sha256: 51cc7336a82a704afe034baa552fd8cce6a1bf086d2460e23119742247972799

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

module RelatonIho
  class IhoBibliographicItem < RelatonBib::BibliographicItem
    # @return [RelatonIho::CommentPeriod, NilClass]
    attr_reader :commentperiod

    # @param editorialgroup [RelatonIho::EditorialGroupCollection]
    # @param commentperiod [RelatonIho::CommentPeriod, NilClass]
    def initialize(**args)
      @commentperiod = args.delete :commentperiod
      super
    end

    #
    # Fetch flavor schema version
    #
    # @return [String] flavor schema version
    #
    def ext_schema
      @ext_schema ||= schema_versions["relaton-model-iho"]
    end

    # @param hash [Hash]
    # @return [RelatonIho::IhoBibliographicItem]
    def self.from_hash(hash)
      item_hash = ::RelatonIho::HashConverter.hash_to_bib(hash)
      new(**item_hash)
    end

    # @param opts [Hash]
    # @option opts [Nokogiri::XML::Builder] :builder XML builder
    # @option opts [Boolean] :bibdata
    # @option opts [String] :lang language
    # @return [String] XML
    def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
      super ext: !commentperiod.nil?, **opts do |b|
        if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
                              ics.any? || commentperiod)
          ext = b.ext do
            doctype&.to_xml b
            editorialgroup&.to_xml b
            ics.each { |i| i.to_xml b }
            commentperiod&.to_xml b
          end
          ext["schema-version"] = ext_schema unless opts[:embedded]
        end
      end
    end

    # @return [Hash]
    def to_hash
      hash = super
      hash["commentperiod"] = commentperiod.to_hash if commentperiod
      hash
    end

    # @param prefix [String]
    # @return [String]
    def to_asciibib(prefix = "")
      out = super
      out += commentperiod.to_asciibib prefix if commentperiod
      out
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
relaton-iho-1.19.1 lib/relaton_iho/iho_bibliographic_item.rb
relaton-iho-1.19.0 lib/relaton_iho/iho_bibliographic_item.rb
relaton-iho-1.18.0 lib/relaton_iho/iho_bibliographic_item.rb
relaton-iho-1.17.0 lib/relaton_iho/iho_bibliographic_item.rb