Class: RelatonNist::NistBibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- RelatonNist::NistBibliographicItem
- Defined in:
- lib/relaton_nist/nist_bibliographic_item.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch flavor schema version.
-
#initialize(**args) ⇒ NistBibliographicItem
constructor
A new instance of NistBibliographicItem.
-
#ref_attrs ⇒ Hash<Symbol=>String>
Create BibXML reference attributes.
- #to_asciibib(prefix = "") ⇒ String
- #to_hash(embedded: false) ⇒ Hash
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
#initialize(**args) ⇒ NistBibliographicItem
Returns a new instance of NistBibliographicItem.
55 56 57 58 59 60 61 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 55 def initialize(**args) # @doctype = args.delete(:doctype) || "standard" # args[:doctype] ||= "standard" # @keyword = args.delete(:keyword) || [] @commentperiod = args.delete :commentperiod super end |
Instance Attribute Details
#commentperiod ⇒ RelatonNist::CommentPeriod? (readonly)
7 8 9 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 7 def commentperiod @commentperiod end |
Class Method Details
.from_hash(hash) ⇒ RelatonNist::GbBibliographicItem
74 75 76 77 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 74 def self.from_hash(hash) item_hash = RelatonNist::HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
#ext_schema ⇒ String
Fetch flavor schema version
68 69 70 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 68 def ext_schema @ext_schema ||= schema_versions["relaton-model-nist"] end |
#ref_attrs ⇒ Hash<Symbol=>String>
Create BibXML reference attributes
118 119 120 121 122 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 118 def ref_attrs docidentifier.detect(&:primary)&.tap do |di| return { anchor: di.id.gsub(" ", ".").squeeze(".") } end end |
#to_asciibib(prefix = "") ⇒ String
107 108 109 110 111 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 107 def to_asciibib(prefix = "") out = super out += commentperiod.to_asciibib prefix if commentperiod out end |
#to_hash(embedded: false) ⇒ Hash
98 99 100 101 102 103 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 98 def to_hash(embedded: false) hash = super # hash["keyword"] = single_element_array(keyword) if keyword&.any? hash["commentperiod"] = commentperiod.to_hash if commentperiod hash end |
#to_xml(**opts) ⇒ String
Returns XML.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/relaton_nist/nist_bibliographic_item.rb', line 84 def to_xml(**opts) super date_format: :short, **opts do |b| if opts[:bibdata] ext = b.ext do doctype&.to_xml b commentperiod&.to_xml b end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |