Class: RelatonIeee::IeeeBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_ieee/ieee_bibliographic_item.rb

Constant Summary collapse

SUBTYPES =
%w[amendment corrigendum erratum].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ IeeeBibliographicItem

Returns a new instance of IeeeBibliographicItem.

Parameters:

  • args (Hash)

Options Hash (**args):

  • :trialuse (Boolean, nil)

    Trial use

  • :editorialgroup (Array<RelatonIeee::EditorialGroup>)

    Editorial group

  • :standard_status (String, nil)

    Active, Inactive, Superseded

  • :standard_modified (String, nil)

    Draft, Withdrawn, Suspended, Approved, Reserved, Redline

  • :pubstatus (String, nil)

    Active, Inactive

  • :holdstatus (String, nil)

    Held, Publish



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 25

def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
    Util.warn "Invalid docsubtype: `#{args[:docsubtype]}`. " \
              "It should be one of: `#{SUBTYPES.join('`, `')}`."
  end
  eg = args.delete(:editorialgroup)
  @trialuse = args.delete(:trialuse)
  @standard_status = args.delete(:standard_status)
  @standard_modified = args.delete(:standard_modified)
  @pubstatus = args.delete(:pubstatus)
  @holdstatus = args.delete(:holdstatus)
  super
  @editorialgroup = eg
end

Instance Attribute Details

#editorialgroupRelatonIeee::EditorialGroup? (readonly)

Returns:



6
7
8
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 6

def editorialgroup
  @editorialgroup
end

#holdstatusString? (readonly)

Returns:

  • (String, nil)


12
13
14
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 12

def holdstatus
  @holdstatus
end

#pubstatusString? (readonly)

Returns:

  • (String, nil)


12
13
14
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 12

def pubstatus
  @pubstatus
end

#standard_modifiedString? (readonly)

Returns:

  • (String, nil)


12
13
14
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 12

def standard_modified
  @standard_modified
end

#standard_statusString? (readonly)

Returns:

  • (String, nil)


12
13
14
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 12

def standard_status
  @standard_status
end

#trialuseBoolean? (readonly)

Returns Trial use.

Returns:

  • (Boolean, nil)

    Trial use



9
10
11
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 9

def trialuse
  @trialuse
end

Class Method Details

.from_hash(hash) ⇒ RelatonIeee::IeeeBibliographicItem

Parameters:

  • hash (Hash)

Returns:



51
52
53
54
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 51

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

Instance Method Details

#ext_schemaString

Fetch flavor schema version

Returns:

  • (String)

    flavor schema version



45
46
47
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 45

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

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


100
101
102
103
104
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 100

def to_asciibib(prefix = "")
  out = super
  out += "#{prefix}.trialuse:: #{trialuse}\n" unless trialuse.nil?
  out
end

#to_hash(embedded: false) ⇒ Hash

Rnder as Hash

Parameters:

  • embedded (Boolean) (defaults to: false)

    emmbedded in other document

Returns:

  • (Hash)


88
89
90
91
92
93
94
95
96
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 88

def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize
  hash = super
  hash["trialuse"] = trialuse unless trialuse.nil?
  hash["ext"]["standard_status"] = standard_status unless standard_status.nil?
  hash["ext"]["standard_modified"] = standard_modified unless standard_modified.nil?
  hash["ext"]["pubstatus"] = pubstatus unless pubstatus.nil?
  hash["ext"]["holdstatus"] = holdstatus unless holdstatus.nil?
  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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/relaton_ieee/ieee_bibliographic_item.rb', line 61

def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  super(**opts) do |bldr|
    if opts[:bibdata] && (doctype || subdoctype || !trialuse.nil? || editorialgroup ||
       ics.any? || standard_status || standard_modified || pubstatus || holdstatus)
      ext = bldr.ext do |b|
        doctype&.to_xml b
        b.subdoctype subdoctype if subdoctype
        b.send :"trial-use", trialuse unless trialuse.nil?
        editorialgroup&.to_xml(b)
        ics.each { |ic| ic.to_xml(b) }
        b.standard_status standard_status if standard_status
        b.standard_modified standard_modified if standard_modified
        b.pubstatus pubstatus if pubstatus
        b.holdstatus holdstatus if holdstatus
      end
      ext["schema-version"] = ext_schema unless opts[:embedded]
    end
  end
end