class RelatonBipm::BipmBibliographicItem

Constants

SI_ASPECTS
STATUSES
TYPES

Attributes

comment_period[R]

@return [RelatonBipm::CommentPeriod, nil]

meeting_note[R]

@return [String, nil]

si_aspect[R]

@return [String, nil]

Public Class Methods

from_hash(hash) click to toggle source

@param hash [Hash] @return [RelatonBipm::BipmBibliographicItem]

# File lib/relaton_bipm/bipm_bibliographic_item.rb, line 47
def self.from_hash(hash)
  item_hash = ::RelatonBipm::HashConverter.hash_to_bib(hash)
  new(**item_hash)
end
new(**args) click to toggle source

@param relation [Array<RelatonBipm::DocumentRelation>] @param editorialgroup [RelatonBipm::EditorialGroup] @param comment_period [RelatonBipm::CommentPeriod, nil] @param si_aspect [String, nil] @param meeting_note [String, nil] @param structuredidentifier [RelatonBipm::StructuredIdentifier]

Calls superclass method
# File lib/relaton_bipm/bipm_bibliographic_item.rb, line 28
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
    warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus].stage.value}. "\
    "It should be one of: #{STATUSES}"
  end

  if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
    warn "[relaton-bipm] Warning: invalid si_aspect: #{args[:si_aspect]}. "\
    "It should be one of: #{SI_ASPECTS}"
  end

  @comment_period = args.delete :comment_period
  @si_aspect = args.delete :si_aspect
  @meeting_note = args[:meeting_note]
  super
end

Public Instance Methods

to_asciibib(prefix = "") click to toggle source

@param prefix [String] @return [String]

Calls superclass method
# File lib/relaton_bipm/bipm_bibliographic_item.rb, line 85
def to_asciibib(prefix = "")
  pref = prefix.empty? ? prefix : "#{prefix}."
  out = super
  out += comment_period.to_asciibib prefix if comment_period
  out += "#{pref}si_aspect:: #{si_aspect}\n" if si_aspect
  out += "#{pref}meeting_note:: #{meeting_note}\h" if meeting_note
  out
end
to_hash() click to toggle source

@return [Hash]

Calls superclass method
# File lib/relaton_bipm/bipm_bibliographic_item.rb, line 75
def to_hash
  hash = super
  hash["comment_period"] = comment_period.to_hash if comment_period
  hash["si_aspect"] = si_aspect if si_aspect
  hash["meeting-note"] = meeting_note if meeting_note
  hash
end
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_bipm/bipm_bibliographic_item.rb, line 57
def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  super ext: !comment_period.nil?, **opts do |b|
    if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
                          si_aspect || comment_period ||
                          structuredidentifier)
      b.ext do
        b.doctype doctype if doctype
        editorialgroup&.to_xml b
        comment_period&.to_xml b
        b.send "si-aspect", si_aspect if si_aspect
        b.send "meeting-note", meeting_note if meeting_note
        structuredidentifier&.to_xml b
      end
    end
  end
end