Class: Relaton3gpp::BibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_3gpp/bibliographic_item.rb

Constant Summary collapse

DOCTYPES =
%w[TR TS].freeze
DOCSUBTYPES =
%w[spec release].freeze
RADIOTECHNOLOGIES =
%w[2G 3G LTE 5G].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ BibliographicItem

Initialize bibliographic item.

Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 14

def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  @radiotechnology = args.delete(:radiotechnology)
  if @radiotechnology && !RADIOTECHNOLOGIES.include?(@radiotechnology)
    warn "[relaton-3gpp] Unknown radiotechnology type: #{@radiotechnology}"
    warn "[relaton-3gpp] Possible radiotechnology types: #{RADIOTECHNOLOGIES.join ' '}"
  end
  @common_ims_spec = args.delete(:common_ims_spec)
  @release = args.delete(:release)
  if args[:doctype].nil? then warn "[relaton-3gpp] doctype is missing"
  elsif !DOCTYPES.include?(args[:doctype])
    warn "[relaton-3gpp] Unknown doctype: #{args[:doctype]}"
    warn "[relaton-3gpp] Possible doctypes: #{DOCTYPES.join ' '}"
  end
  if args[:docsubtype] && !DOCSUBTYPES.include?(args[:docsubtype])
    warn "[relaton-3gpp] Unknown docsubtype: #{args[:docsubtype]}"
    warn "[relaton-3gpp] Possible docsubtypes: #{DOCSUBTYPES.join ' '}"
  end
  super(**args)
end

Instance Method Details

#has_ext_attrs?Boolean

rubocop:disable Metrics/CyclomaticComplexity

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 56

def has_ext_attrs? # rubocop:disable Metrics/CyclomaticComplexity
  doctype || subdoctype || editorialgroup || ics.any? || @radiotechnology ||
    @common_ims_spec || @release
end

#to_hashHash

Convert to hash.

Returns:

  • (Hash)

    Hash



66
67
68
69
70
71
72
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 66

def to_hash
  hash = super
  hash["radiotechnology"] = @radiotechnology if @radiotechnology
  hash["common-ims-spec"] = @common_ims_spec if @common_ims_spec
  hash["release"] = @release.to_hash if @release
  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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 39

def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  super do |b|
    if block_given? then yield b
    elsif opts[:bibdata] && has_ext_attrs?
      b.ext do
        b.doctype doctype if doctype
        b.subdoctype subdoctype if subdoctype
        editorialgroup&.to_xml b
        ics.each { |i| i.to_xml b }
        b.radiotechnology @radiotechnology if @radiotechnology
        b.send "common-ims-spec", @common_ims_spec if @common_ims_spec
        @release&.to_xml b if @release
      end
    end
  end
end