Class: RelatonBsi::BsiBibliographicItem

Inherits:
RelatonIsoBib::IsoBibliographicItem
  • Object
show all
Defined in:
lib/relaton_bsi/bsi_bibliographic_item.rb

Constant Summary collapse

TYPES =
%w[
  british-standard draft-for-development published-document privately-subscribed-standard
  publicly-available-specification flex-standard international-standard technical-specification
  technical-report guide international-workshop-agreement industry-technical-agreement
  standard european-workshop-agreement fast-track-standard
].freeze
SUBDOCTYPES =
%w[specification method-of-test method-of-specifying vocabulary code-of-practice].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ BsiBibliographicItem

Returns a new instance of BsiBibliographicItem.

Parameters:

  • cen_processing (Boolean, nil)


14
15
16
17
18
19
20
21
22
23
24
# 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

Class Method Details

.from_hash(hash) ⇒ RelatonBsi::BsiBibliographicItem

Parameters:

  • hash (Hash)

Returns:



49
50
51
52
# 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

Instance Method Details

#to_xml(**opts) ⇒ String

Returns XML.

Parameters:

  • opts (Hash)

Options Hash (**opts):

  • :builder (Nokogiri::XML::Builder)

    XML builder

  • :bibdata (Boolean)
  • :lang (String)

    language

Returns:

  • (String)

    XML



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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