Class: Relaton3gpp::BibliographicItem

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ BibliographicItem

Initialize bibliographic item.

Parameters:



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

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

Instance Attribute Details

#radiotechnologyString? (readonly)

Returns:

  • (String, nil)


7
8
9
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 7

def radiotechnology
  @radiotechnology
end

#releaseString? (readonly)

Returns:

  • (String, nil)


7
8
9
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 7

def release
  @release
end

Instance Method Details

#ext_schemaString

Fetch the flavor shcema version

Returns:

  • (String)

    schema version



37
38
39
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 37

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

#has_ext_attrs?Boolean

rubocop:disable Metrics/CyclomaticComplexity

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 76

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

#makeid(identifier, attribute) ⇒ String?

Returns id.

Parameters:

  • identifier (RelatonBib::DocumentIdentifier, nil)

    <description>

  • attribute (Boolean, nil)

    true if the ID attribute is needed

Returns:

  • (String, nil)

    id



49
50
51
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 49

def makeid(identifier, attribute)
  super&.sub(/^3GPP/, "")
end

#to_hash(embedded: false) ⇒ Hash

Convert to hash.

Returns:

  • (Hash)

    Hash



86
87
88
89
90
91
92
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 86

def to_hash(embedded: false)
  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



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 58

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?
      ext = b.ext do
        doctype&.to_xml b
        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
      end
      ext["schema-version"] = ext_schema unless opts[:embedded]
    end
  end
end