Class: RelatonGb::GbBibliographicItem
- Inherits:
-
RelatonIsoBib::IsoBibliographicItem
- Object
- RelatonIsoBib::IsoBibliographicItem
- RelatonGb::GbBibliographicItem
- Defined in:
- lib/relaton_gb/gb_bibliographic_item.rb
Overview
GB bibliographic item class.
Constant Summary collapse
- SUBDOCTYPES =
%w[specification method-of-test vocabulary code-of-practice].freeze
Instance Attribute Summary collapse
- #ccs ⇒ Array<Cnccs::Ccs> readonly
- #committee ⇒ RelatonGb::GbTechnicalCommittee readonly
- #gbplannumber ⇒ String readonly
- #gbtype ⇒ RelatonGb::GbStandardType readonly
- #plan_number ⇒ String readonly
- #topic ⇒ String readonly
- #type ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #ext_schema ⇒ Object
- #has_ext? ⇒ Boolean
-
#initialize(**args) ⇒ GbBibliographicItem
constructor
A new instance of GbBibliographicItem.
- #inspect ⇒ String
- #makeid(id, attribute, _delim = "") ⇒ Object
- #to_asciibib(prefix = "") ⇒ String
- #to_hash ⇒ Hash
- #to_s ⇒ String
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
permalink #initialize(**args) ⇒ GbBibliographicItem
Returns a new instance of GbBibliographicItem.
32 33 34 35 36 37 38 39 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 32 def initialize(**args) super @committee = GbTechnicalCommittee.new(**args[:committee]) if args[:committee] @ccs = args[:ccs].map { |c| c.is_a?(Cnccs::Ccs) ? c : Cnccs.fetch(c) } @gbtype = GbStandardType.new(**args[:gbtype]) @gbplannumber = args[:gbplannumber] || structuredidentifier&.project_number end |
Instance Attribute Details
permalink #ccs ⇒ Array<Cnccs::Ccs> (readonly)
24 25 26 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 24 def ccs @ccs end |
permalink #committee ⇒ RelatonGb::GbTechnicalCommittee (readonly)
15 16 17 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 15 def committee @committee end |
permalink #gbplannumber ⇒ String (readonly)
30 31 32 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 30 def gbplannumber @gbplannumber end |
permalink #gbtype ⇒ RelatonGb::GbStandardType (readonly)
18 19 20 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 18 def gbtype @gbtype end |
permalink #plan_number ⇒ String (readonly)
27 28 29 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 27 def plan_number @plan_number end |
permalink #topic ⇒ String (readonly)
21 22 23 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 21 def topic @topic end |
permalink #type ⇒ String (readonly)
30 31 32 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 30 def type @type end |
Class Method Details
permalink .from_hash(hash) ⇒ RelatonGb::GbBibliographicItem
47 48 49 50 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 47 def self.from_hash(hash) item_hash = ::RelatonGb::HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
permalink #ext_schema ⇒ Object
[View source]
41 42 43 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 41 def ext_schema @ext_schema ||= schema_versions["relaton-model-gb"] end |
permalink #has_ext? ⇒ Boolean
86 87 88 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 86 def has_ext? super || ccs&.any? || committee || gbplannumber || gbtype end |
permalink #inspect ⇒ String
99 100 101 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 99 def inspect "<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)}>" end |
permalink #makeid(id, attribute, _delim = "") ⇒ Object
[View source]
108 109 110 111 112 113 114 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 108 def makeid(id, attribute, _delim = "") return nil if attribute && !@id_attribute id ||= @docidentifier.reject { |i| i.type == "DOI" }[0] idstr = id.id idstr.gsub(/\s/, "").strip end |
permalink #to_asciibib(prefix = "") ⇒ String
92 93 94 95 96 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 92 def to_asciibib(prefix = "") out = super ccs.each { |c| out += c.to_aciibib prefix, ccs.size } out end |
permalink #to_hash ⇒ Hash
77 78 79 80 81 82 83 84 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 77 def to_hash # rubocop:disable Metrics/AbcSize hash = super hash["ext"]["ccs"] = single_element_array(ccs) if ccs&.any? hash["ext"]["committee"] = committee.to_hash if committee hash["ext"]["plannumber"] = gbplannumber if gbplannumber hash["ext"]["gbtype"] = gbtype.to_hash if gbtype hash end |
permalink #to_s ⇒ String
104 105 106 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 104 def to_s inspect end |
permalink #to_xml(**opts) ⇒ String
Returns XML.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 58 def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity super(**opts) do |b| if opts[:bibdata] && has_ext? ext = b.ext do doctype&.to_xml b b.horizontal horizontal unless horizontal.nil? # b.docsubtype docsubtype if docsubtype committee&.to_xml b ics.each { |i| i.to_xml b } structuredidentifier&.to_xml b b.stagename stagename if stagename render_gbxml(b) end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |