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
- DOCTYPES =
%w[ international-standard technical-specification technical-report publicly-available-specification international-workshop-agreement guide amendment technical-corrigendum directive ].freeze
- SUBDOCTYPES =
%w[specification method-of-test vocabulary code-of-practice].freeze
Instance Attribute Summary collapse
- #doctype ⇒ String, NilClass readonly
- #editorialgroup ⇒ RelatonIsoBib::EditorialGroup readonly
- #horizontal ⇒ Boolean? readonly
- #ics ⇒ Array<RelatonIsoBib::Ics> readonly
- #stagename ⇒ String, NilClass readonly
- #structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier readonly
- #title ⇒ Array<RelatonBib::TypedTitleString> 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.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 133 def initialize(**args) check_doctype args[:doctype] 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] && !SUBDOCTYPES.include?(args[:subdoctype]) warn "Invald subdoctype '#{args[:subdoctype]}'. Allowed values are: #{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 end |
Instance Attribute Details
#doctype ⇒ String, NilClass (readonly)
39 40 41 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 39 def doctype @doctype end |
#editorialgroup ⇒ RelatonIsoBib::EditorialGroup (readonly)
45 46 47 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 45 def editorialgroup @editorialgroup end |
#horizontal ⇒ Boolean? (readonly)
42 43 44 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 42 def horizontal @horizontal end |
#ics ⇒ Array<RelatonIsoBib::Ics> (readonly)
48 49 50 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 48 def ics @ics end |
#stagename ⇒ String, NilClass (readonly)
39 40 41 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 39 def stagename @stagename end |
#structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier (readonly)
33 34 35 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 33 def structuredidentifier @structuredidentifier end |
#title ⇒ Array<RelatonBib::TypedTitleString> (readonly)
|
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 35
|
Instance Method Details
#ext_schema ⇒ String
Fetch the flavour schema version
169 170 171 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 169 def ext_schema @ext_schema ||= schema_versions["relaton-model-iso"] end |
#to_asciibib(prefix = "") ⇒ String
221 222 223 224 225 226 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 221 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}." out = super out += "#{pref}stagename:: #{stagename}\n" if stagename out end |
#to_hash(embedded: false) ⇒ Hash
Render the document as HASH
212 213 214 215 216 217 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 212 def to_hash(embedded: false) hash = super hash["horizontal"] = horizontal unless horizontal.nil? hash["stagename"] = stagename if stagename hash end |
#to_xml(**opts) ⇒ String
Render the document as an XML string.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 184 def to_xml(**opts) super(**opts) do |b| if block_given? then yield b elsif opts[:bibdata] && has_ext_attrs? ext = b.ext do b.doctype doctype 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 end ext["schema-version"] = ext_schema unless opts[:embedded] end end end |