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
- TYPES =
%w[ international-standard technical-specification technical-report publicly-available-specification international-workshop-agreement guide ].freeze
Instance Attribute Summary collapse
- #doctype ⇒ String, NilClass readonly
- #editorialgroup ⇒ RelatonIsoBib::EditorialGroup readonly
- #ics ⇒ Array<RelatonIsoBib::Ics> readonly
- #structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier readonly
- #title(lang: nil) ⇒ Array<RelatonIsoBib::TypedTitleString> readonly
Instance Method Summary collapse
-
#disable_id_attribute ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity.
-
#initialize(**args) ⇒ IsoBibliographicItem
constructor
A new instance of IsoBibliographicItem.
-
#to_all_parts ⇒ Object
remove title part components and abstract.
-
#to_most_recent_reference ⇒ Object
convert ISO:yyyy reference to reference to most recent instance of reference, removing date-specific infomration: date of publication, abstracts.
- #to_xml(builder = nil, **opts, &block) ⇒ String
- #url(type = :src) ⇒ String
Constructor Details
#initialize(**args) ⇒ IsoBibliographicItem
Returns a new instance of IsoBibliographicItem.
124 125 126 127 128 129 130 131 132 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 163 164 165 166 167 168 169 170 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 124 def initialize(**args) if args[:type] && !TYPES.include?(args[:type]) raise ArgumentError, "invalid type: #{args[:type]}" end args.fetch(:language, []).each do |lang| unless %w[en fr].include? lang raise ArgumentError, "invalid language: #{lang}" end end args.fetch(:script, []).each do |scr| raise ArgumentError, "invalid script: #{scr}" unless scr == "Latn" end super_args = args.select do |k| %i[id docnumber language script docstatus dates abstract contributors edition version relations biblionote series medium place copyright link fetched docid formattedref extent accesslocation classification validity].include? k end super(super_args) @structuredidentifier = args[:structuredidentifier] @title = args.fetch(:titles, []).reduce([]) do |a, t| if t.is_a? Hash a + typed_titles(t) else a << t end end if args[:editorialgroup] @editorialgroup = if args[:editorialgroup].is_a?(Hash) EditorialGroup.new(args[:editorialgroup]) else args[:editorialgroup] end end @doctype = args[:type] @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i } @link = args.fetch(:link, []).map do |s| s.is_a?(Hash) ? RelatonBib::TypedUri.new(s) : s end @id_attribute = true end |
Instance Attribute Details
#doctype ⇒ String, NilClass (readonly)
37 38 39 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 37 def doctype @doctype end |
#editorialgroup ⇒ RelatonIsoBib::EditorialGroup (readonly)
40 41 42 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 40 def editorialgroup @editorialgroup end |
#ics ⇒ Array<RelatonIsoBib::Ics> (readonly)
43 44 45 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 43 def ics @ics end |
#structuredidentifier ⇒ RelatonIsoBib::StructuredIdentifier (readonly)
31 32 33 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 31 def structuredidentifier @structuredidentifier end |
#title(lang: nil) ⇒ Array<RelatonIsoBib::TypedTitleString> (readonly)
|
|
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 33
|
Instance Method Details
#disable_id_attribute ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
174 175 176 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 174 def disable_id_attribute @id_attribute = false end |
#to_all_parts ⇒ Object
remove title part components and abstract
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 179 def to_all_parts me = DeepClone.clone(self) me.disable_id_attribute @relations << RelatonBib::DocumentRelation.new( type: "partOf", bibitem: me, ) @title.delete_if { |t| t.type == "title-part" } @abstract = [] @docidentifier.each(&:remove_part) @docidentifier.each(&:all_parts) @structuredidentifier.remove_part @structuredidentifier.all_parts @all_parts = true end |
#to_most_recent_reference ⇒ Object
convert ISO:yyyy reference to reference to most recent instance of reference, removing date-specific infomration: date of publication, abstracts. Make dated reference Instance relation of the redacated document
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 198 def to_most_recent_reference me = DeepClone.clone(self) me.disable_id_attribute @relations << RelatonBib::DocumentRelation.new(type: "instance", bibitem: me) @abstract = [] @dates = [] @docidentifier.each &:remove_date @structuredidentifier.remove_date @id&.sub! /-[12]\d\d\d/, "" end |
#to_xml(builder = nil, **opts, &block) ⇒ String
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 226 def to_xml(builder = nil, **opts, &block) if opts[:note] && !opts[:note].empty? opts.fetch(:note, []).each do |n| @biblionote << RelatonBib::BiblioNote.new( content: n[:text], type: n[:type], format: "text/plain" ) end end super builder, **opts do |b| if opts[:bibdata] b.ext do b.doctype doctype if doctype editorialgroup&.to_xml b ics.each { |i| i.to_xml b } structuredidentifier.to_xml b end end end end |
#url(type = :src) ⇒ String
221 222 223 |
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 221 def url(type = :src) @link.detect { |s| s.type == type.to_s }.content.to_s end |