Class: RelatonIetf::IetfBibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- RelatonIetf::IetfBibliographicItem
- Defined in:
- lib/relaton_ietf/ietf_bibliographic_item.rb
Instance Attribute Summary collapse
- #keyword ⇒ Array<String> readonly
- #stream ⇒ String? readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch flavor schema version.
- #has_ext? ⇒ Boolean
-
#initialize(**args) ⇒ IetfBibliographicItem
constructor
A new instance of IetfBibliographicItem.
-
#to_bibxml(builder = nil, include_keywords: false) ⇒ String, Nokogiri::XML::Builder::NodeBuilder
Render BibXML (RFC).
-
#to_hash(embedded: false) ⇒ Hash
Render hash.
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
#initialize(**args) ⇒ IetfBibliographicItem
Returns a new instance of IetfBibliographicItem.
11 12 13 14 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 11 def initialize(**args) @stream = args.delete(:stream) super end |
Instance Attribute Details
#keyword ⇒ Array<String> (readonly)
7 8 9 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 7 def keyword @keyword end |
#stream ⇒ String? (readonly)
4 5 6 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 4 def stream @stream end |
Class Method Details
.from_hash(hash) ⇒ RelatonIetf::IetfBibliographicItem
27 28 29 30 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 27 def self.from_hash(hash) item_hash = ::RelatonIetf::HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
#ext_schema ⇒ String
Fetch flavor schema version
21 22 23 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 21 def ext_schema @ext_schema ||= schema_versions["relaton-model-ietf"] end |
#has_ext? ⇒ Boolean
70 71 72 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 70 def has_ext? super || stream end |
#to_bibxml(builder = nil, include_keywords: false) ⇒ String, Nokogiri::XML::Builder::NodeBuilder
Render BibXML (RFC)
82 83 84 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 82 def to_bibxml(builder = nil, include_keywords: false) Renderer::BibXML.new(self).render builder: builder, include_keywords: include_keywords end |
#to_hash(embedded: false) ⇒ Hash
Render hash
61 62 63 64 65 66 67 68 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 61 def to_hash(embedded: false) hash = super return hash unless stream hash["ext"] ||= {} hash["ext"]["stream"] = stream hash end |
#to_xml(**opts) ⇒ String
Returns XML.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 38 def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength opts[:date_format] ||= :short super(**opts) do |builder| if opts[:bibdata] && (doctype || editorialgroup || ics&.any? || structuredidentifier&.presence? || stream) ext = builder.ext do |b| doctype&.to_xml b b.subdoctype subdoctype if subdoctype editorialgroup&.to_xml b ics.each { |i| i.to_xml b } b.stream stream if stream structuredidentifier&.to_xml b end ext["schema-version"] = ext_schema if !opts[:embedded] && respond_to?(:ext_schema) end end end |