Class: Relaton3gpp::BibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- Relaton3gpp::BibliographicItem
- 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
-
#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.
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
#ext_schema ⇒ String
Fetch the flavor shcema version
39 40 41 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 39 def ext_schema @ext_schema ||= schema_versions["relaton-model-3gpp"] end |
#has_ext_attrs? ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity
78 79 80 81 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 78 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.
51 52 53 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 51 def makeid(identifier, attribute) super&.sub(/^3GPP/, "") end |
#to_hash ⇒ Hash
Convert to hash.
88 89 90 91 92 93 94 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 88 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.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/relaton_3gpp/bibliographic_item.rb', line 60 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 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 end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |