Class: RelatonEtsi::BibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- RelatonEtsi::BibliographicItem
- Defined in:
- lib/relaton_etsi/bibliographic_item.rb
Constant Summary collapse
- MAKER =
%w[Current Superseded].freeze
- CUSTOM_COLLECTION =
["HSs cited in OJ", "HSs not yet cited in OJ", "HSs RED cited in OJ", "HSs EMC cited in OJ"].freeze
Instance Attribute Summary collapse
-
#custom_collection ⇒ Object
readonly
Returns the value of attribute custom_collection.
-
#frequency ⇒ Object
readonly
Returns the value of attribute frequency.
-
#mandate ⇒ Object
readonly
Returns the value of attribute mandate.
-
#marker ⇒ Object
readonly
Returns the value of attribute marker.
Class Method Summary collapse
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch flavour schema version.
-
#initialize(**args) ⇒ BibliographicItem
constructor
Constructor.
-
#to_asciibib(prefix = "") ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#to_hash ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#to_xml(**opts) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity.
Constructor Details
#initialize(**args) ⇒ BibliographicItem
Constructor.
17 18 19 20 21 22 23 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 17 def initialize(**args) @marker = args.delete(:marker) @frequency = args.delete(:frequency) || [] @mandate = args.delete(:mandate) || [] @custom_collection = args.delete(:custom_collection) super(**args) end |
Instance Attribute Details
#custom_collection ⇒ Object (readonly)
Returns the value of attribute custom_collection.
6 7 8 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 6 def custom_collection @custom_collection end |
#frequency ⇒ Object (readonly)
Returns the value of attribute frequency.
6 7 8 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 6 def frequency @frequency end |
#mandate ⇒ Object (readonly)
Returns the value of attribute mandate.
6 7 8 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 6 def mandate @mandate end |
#marker ⇒ Object (readonly)
Returns the value of attribute marker.
6 7 8 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 6 def marker @marker end |
Class Method Details
.from_hash(hash) ⇒ Object
25 26 27 28 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 25 def self.from_hash(hash) item_hash = HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
#ext_schema ⇒ String
Fetch flavour schema version
35 36 37 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 35 def ext_schema @ext_schema ||= schema_versions["relaton-model-etsi"] end |
#to_asciibib(prefix = "") ⇒ Object
rubocop:disable Metrics/AbcSize
65 66 67 68 69 70 71 72 73 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 65 def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize out = super pref = prefix.empty? ? prefix : "#{prefix}." out += "#{pref}marker:: #{marker}\n" if marker out += frequency.map { |f| "#{pref}frequency:: #{f}\n" }.join out += mandate.map { |m| "#{pref}mandate:: #{m}\n" }.join out += "#{pref}custom_collection:: #{custom_collection}" if custom_collection out end |
#to_hash ⇒ Object
rubocop:disable Metrics/AbcSize
56 57 58 59 60 61 62 63 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 56 def to_hash # rubocop:disable Metrics/AbcSize hash = super hash["marker"] = marker if marker hash["frequency"] = frequency if frequency.any? hash["mandate"] = mandate if mandate.any? hash["custom_collection"] = custom_collection if custom_collection hash end |
#to_xml(**opts) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/relaton_etsi/bibliographic_item.rb', line 39 def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity super(**opts) do |b| if opts[:bibdata] && (doctype || subdoctype || editorialgroup || marker || frequency.any? || mandate.any? || custom_collection) ext = b.ext do doctype&.to_xml b b.subdoctype subdoctype if subdoctype editorialgroup&.to_xml b b.marker marker if marker frequency.each { |f| b.frequency f } mandate.each { |m| b.mandate m } b.send("custom-collection", custom_collection) if custom_collection end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |