Class: RelatonBipm::BipmBibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- RelatonBipm::BipmBibliographicItem
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bipm/bipm_bibliographic_item.rb
Constant Summary collapse
- STATUSES =
%w[draft-proposal draft-development in-force retired].freeze
- SI_ASPECTS =
%w[ A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu K_k kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA s_deltanu ].freeze
Instance Attribute Summary collapse
- #comment_period ⇒ RelatonBipm::CommentPeriod? readonly
- #meeting_note ⇒ String? readonly
- #si_aspect ⇒ String? readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch flavour schema version.
-
#initialize(**args) ⇒ BipmBibliographicItem
constructor
A new instance of BipmBibliographicItem.
- #to_asciibib(prefix = "") ⇒ String
-
#to_hash(embedded: false) ⇒ Hash
Rnder document as Hash.
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
#initialize(**args) ⇒ BipmBibliographicItem
Returns a new instance of BipmBibliographicItem.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 24 def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value) Util.warn "Invalid docstatus: `#{args[:docstatus].stage.value}`. " \ "It should be one of: `#{STATUSES.join('`, `')}`" end if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect]) Util.warn "Invalid si_aspect: `#{args[:si_aspect]}``. " \ "It should be one of: `#{SI_ASPECTS.join('`, `')}`" end @comment_period = args.delete :comment_period @si_aspect = args.delete :si_aspect @meeting_note = args[:meeting_note] super end |
Instance Attribute Details
#comment_period ⇒ RelatonBipm::CommentPeriod? (readonly)
13 14 15 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 13 def comment_period @comment_period end |
#meeting_note ⇒ String? (readonly)
16 17 18 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 16 def meeting_note @meeting_note end |
#si_aspect ⇒ String? (readonly)
16 17 18 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 16 def si_aspect @si_aspect end |
Class Method Details
.from_hash(hash) ⇒ RelatonBipm::BipmBibliographicItem
52 53 54 55 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 52 def self.from_hash(hash) item_hash = ::RelatonBipm::HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
#ext_schema ⇒ String
Fetch flavour schema version
46 47 48 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 46 def ext_schema @ext_schema ||= schema_versions["relaton-model-bipm"] end |
#to_asciibib(prefix = "") ⇒ String
97 98 99 100 101 102 103 104 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 97 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}." out = super out += comment_period.to_asciibib prefix if comment_period out += "#{pref}si_aspect:: #{si_aspect}\n" if si_aspect out += "#{pref}meeting_note:: #{meeting_note}\h" if meeting_note out end |
#to_hash(embedded: false) ⇒ Hash
Rnder document as Hash
87 88 89 90 91 92 93 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 87 def to_hash(embedded: false) hash = super hash["comment_period"] = comment_period.to_hash if comment_period hash["si_aspect"] = si_aspect if si_aspect hash["meeting_note"] = meeting_note if meeting_note hash end |
#to_xml(**opts) ⇒ String
Returns XML.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/relaton_bipm/bipm_bibliographic_item.rb', line 62 def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity super ext: !comment_period.nil?, **opts do |b| if opts[:bibdata] && (doctype || editorialgroup&.presence? || si_aspect || comment_period || structuredidentifier) ext = b.ext do doctype&.to_xml b editorialgroup&.to_xml b comment_period&.to_xml b b.send :"si-aspect", si_aspect if si_aspect b.send :"meeting-note", meeting_note if meeting_note structuredidentifier&.to_xml b end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |