Class: RelatonIsoBib::IsoBibliographicItem
- Inherits:
-
RelatonBib::BibliographicItem
- Object
- RelatonBib::BibliographicItem
- RelatonIsoBib::IsoBibliographicItem
- Defined in:
- lib/relaton_iso_bib/iso_bibliographic_item.rb
Overview
Bibliographic item.
Constant Summary collapse
- SUBDOCTYPES =
%w[specification method-of-test vocabulary code-of-practice].freeze
Instance Attribute Summary collapse
- #editorialgroup ⇒ RelatonIsoBib::EditorialGroup readonly
- #fast_track ⇒ Boolean? readonly
- #horizontal ⇒ Boolean? readonly
- #ics ⇒ Array<RelatonIsoBib::Ics> readonly
- #price_code ⇒ String? readonly
- #stagename ⇒ String? readonly
- #structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier readonly
- #subdoctype ⇒ RelatonIsoBib::DocumentType readonly
Instance Method Summary collapse
-
#ext_schema ⇒ String
Fetch the flavour schema version.
-
#initialize(**args) ⇒ IsoBibliographicItem
constructor
A new instance of IsoBibliographicItem.
- #to_asciibib(prefix = "") ⇒ String
-
#to_hash(embedded: false) ⇒ Hash
Render the document as HASH.
-
#to_xml(**opts) ⇒ String
Render the document as an XML string.
Constructor Details
#initialize(**args) ⇒ IsoBibliographicItem
Returns a new instance of IsoBibliographicItem.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 111 def initialize(**args) args[:type] ||= "standard" arg_names = %i[ id title docnumber language script docstatus date abstract contributor edition version relation biblionote series medium place copyright link fetched docid formattedref extent accesslocation classification validity editorialgroup doctype keyword type ] super_args = args.select { |k| arg_names.include? k } super(**super_args) if args[:editorialgroup] @editorialgroup = if args[:editorialgroup].is_a?(Hash) EditorialGroup.new(**args[:editorialgroup]) else args[:editorialgroup] end end if args[:subdoctype] && !self.class::SUBDOCTYPES.include?(args[:subdoctype]) Util.warn "Invald subdoctype `#{args[:subdoctype]}`. Allowed values are: #{self.class::SUBDOCTYPES.join(', ')}" end @subdoctype = args[:subdoctype] @structuredidentifier = args[:structuredidentifier] @horizontal = args[:horizontal] @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(**i) : i } @stagename = args[:stagename] @id_attribute = true @fast_track = args[:fast_track] @price_code = args[:price_code] if args.key? :price_code # @TODO: remove `if` when all users update relaton-iec end |
Instance Attribute Details
#editorialgroup ⇒ RelatonIsoBib::EditorialGroup (readonly)
27 28 29 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 27 def editorialgroup @editorialgroup end |
#fast_track ⇒ Boolean? (readonly)
24 25 26 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 24 def fast_track @fast_track end |
#horizontal ⇒ Boolean? (readonly)
24 25 26 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 24 def horizontal @horizontal end |
#ics ⇒ Array<RelatonIsoBib::Ics> (readonly)
30 31 32 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 30 def ics @ics end |
#price_code ⇒ String? (readonly)
18 19 20 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 18 def price_code @price_code end |
#stagename ⇒ String? (readonly)
18 19 20 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 18 def stagename @stagename end |
#structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier (readonly)
15 16 17 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 15 def structuredidentifier @structuredidentifier end |
#subdoctype ⇒ RelatonIsoBib::DocumentType (readonly)
|
|
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 20
|
Instance Method Details
#ext_schema ⇒ String
Fetch the flavour schema version
147 148 149 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 147 def ext_schema @ext_schema ||= schema_versions["relaton-model-iso"] end |
#to_asciibib(prefix = "") ⇒ String
203 204 205 206 207 208 209 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 203 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}." out = super out += "#{pref}stagename:: #{stagename}\n" if stagename out += "#{pref}fast-track:: #{fast_track}\n" unless fast_track.nil? out end |
#to_hash(embedded: false) ⇒ Hash
Render the document as HASH
192 193 194 195 196 197 198 199 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 192 def to_hash(embedded: false) hash = super hash["horizontal"] = horizontal unless horizontal.nil? hash["stagename"] = stagename if stagename hash["fast_track"] = fast_track unless fast_track.nil? hash["price_code"] = price_code if price_code hash end |
#to_xml(**opts) ⇒ String
Render the document as an XML string.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 162 def to_xml(**opts) super(**opts) do |b| if block_given? then yield b elsif opts[:bibdata] && has_ext_attrs? ext = b.ext do doctype.to_xml b if doctype b.subdoctype subdoctype if subdoctype b.horizontal horizontal unless horizontal.nil? editorialgroup&.to_xml b ics.each { |i| i.to_xml b } structuredidentifier&.to_xml b b.stagename stagename if stagename b.send("fast-track", fast_track) unless fast_track.nil? b.send("price-code", price_code) if price_code end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |