Class: Relaton3gpp::BibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- Relaton3gpp::BibliographicItem
- Defined in:
- lib/relaton_3gpp/bibliographic_item.rb
Constant Summary collapse
- DOCSUBTYPES =
%w[spec release].freeze
- RADIOTECHNOLOGIES =
%w[2G 3G LTE 5G].freeze
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch the flavor shcema version.
-
#has_ext_attrs? ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity.
-
#initialize(**args) ⇒ BibliographicItem
constructor
Initialize bibliographic item.
-
#makeid(identifier, attribute) ⇒ String?
Id.
-
#to_hash ⇒ Hash
Convert to hash.
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
#initialize(**args) ⇒ BibliographicItem
Initialize bibliographic item.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 13 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 Method Details
#ext_schema ⇒ String
Fetch the flavor shcema version
34 35 36 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 34 def ext_schema @ext_schema ||= schema_versions["relaton-model-3gpp"] end |
#has_ext_attrs? ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity
73 74 75 76 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 73 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.
46 47 48 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 46 def makeid(identifier, attribute) super&.sub(/^3GPP/, "") end |
#to_hash ⇒ Hash
Convert to hash.
83 84 85 86 87 88 89 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 83 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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 55 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 |