Class: RelatonIho::IhoBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_iho/iho_bibliographic_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ IhoBibliographicItem

Returns a new instance of IhoBibliographicItem.

Parameters:



8
9
10
11
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 8

def initialize(**args)
  @commentperiod = args.delete :commentperiod
  super
end

Instance Attribute Details

#commentperiodRelatonIho::CommentPeriod, NilClass (readonly)

Returns:

  • (RelatonIho::CommentPeriod, NilClass)


4
5
6
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 4

def commentperiod
  @commentperiod
end

Class Method Details

.from_hash(hash) ⇒ RelatonIho::IhoBibliographicItem

Parameters:

  • hash (Hash)

Returns:



24
25
26
27
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 24

def self.from_hash(hash)
  item_hash = ::RelatonIho::HashConverter.hash_to_bib(hash)
  new(**item_hash)
end

Instance Method Details

#ext_schemaString

Fetch flavor schema version

Returns:

  • (String)

    flavor schema version



18
19
20
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 18

def ext_schema
  @ext_schema ||= schema_versions["relaton-model-iho"]
end

#to_asciibib(prefix = "") ⇒ String

Parameters:

  • prefix (String) (defaults to: "")

Returns:

  • (String)


58
59
60
61
62
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 58

def to_asciibib(prefix = "")
  out = super
  out += commentperiod.to_asciibib prefix if commentperiod
  out
end

#to_hashHash

Returns:

  • (Hash)


50
51
52
53
54
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 50

def to_hash
  hash = super
  hash["commentperiod"] = commentperiod.to_hash if commentperiod
  hash
end

#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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/relaton_iho/iho_bibliographic_item.rb', line 34

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