class RelatonBsi::BsiBibliographicItem

Constants

SUBDOCTYPES
TYPES

Public Class Methods

from_hash(hash) click to toggle source

@param hash [Hash] @return [RelatonBsi::BsiBibliographicItem]

# File lib/relaton_bsi/bsi_bibliographic_item.rb, line 49
def self.from_hash(hash)
  item_hash = ::RelatonBsi::HashConverter.hash_to_bib(hash)
  new(**item_hash)
end
new(**args) click to toggle source

@params price_code [String, nil] @param cen_processing [Boolean, nil]

Calls superclass method
# File lib/relaton_bsi/bsi_bibliographic_item.rb, line 14
def initialize(**args) # rubocop:disable Metrics/AbcSize
  # if args[:doctype] && !TYPES.include?(args[:doctype])
  #   warn "[relaton-bsi] WARNING: invalid doctype: #{args[:doctype]}"
  #   warn "[relaton-bsi] Allowed doctypes are: #{TYPES.join(', ')}"
  # end
  if args[:subdoctype] && !SUBDOCTYPES.include?(args[:subdoctype])
    warn "[relaton-bsi] WARNING: invalid subdoctype: #{args[:subdoctype]}"
    warn "[relaton-bsi] Allowed subdoctypes are: #{SUBDOCTYPES.join(', ')}"
  end
  super
end

Public Instance Methods

to_xml(**opts) click to toggle source

@param opts [Hash] @option opts [Nokogiri::XML::Builder] :builder XML builder @option opts [Boolean] :bibdata @option opts [String] :lang language @return [String] XML

Calls superclass method
# File lib/relaton_bsi/bsi_bibliographic_item.rb, line 31
def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
  super(**opts) do |b|
    if opts[:bibdata] && (has_ext_attrs? || price_code ||
      !cen_processing.nil?)
      b.ext do
        b.doctype doctype if doctype
        b.horizontal horizontal unless horizontal.nil?
        editorialgroup&.to_xml b
        ics.each { |i| i.to_xml b }
        structuredidentifier&.to_xml b
        b.stagename stagename if stagename
      end
    end
  end
end