Class: IsoBibItem::BibliographicItem
- Inherits:
-
Object
- Object
- IsoBibItem::BibliographicItem
- Defined in:
- lib/iso_bib_item/bibliographic_item.rb
Overview
Bibliographic item
Direct Known Subclasses
Instance Attribute Summary collapse
- #abstract(lang: nil) ⇒ IsoBibItem::FormattedString+ readonly
- #contributors ⇒ Array<IsoBibItem::ContributionInfo> readonly
- #copyright ⇒ IsoBibItem::CopyrightAssociation readonly
- #dates ⇒ Array<IsoBibItem::BibliographicDate> readonly
- #docidentifier ⇒ Array<IsoBibItem::DocumentIdentifier> readonly
- #edition ⇒ String readonly
- #formatted_ref ⇒ IsoBibItem::FormattedString readonly
- #id ⇒ String readonly
-
#language ⇒ Array<String>
readonly
Language Iso639 code.
- #link ⇒ Array<IsoBibItem::TypedUri> readonly
- #notes ⇒ Array<IsoBibItem::FormattedString> readonly
- #relations ⇒ IsoBibItem::DocRelationCollection readonly
-
#script ⇒ Array<String>
readonly
Script Iso15924 code.
- #series ⇒ Array<IsoBibItem::Series> readonly
- #status ⇒ IsoBibItem::DocumentStatus readonly
- #title ⇒ Array<IsoBibItem::FormattedString> readonly
- #type ⇒ IsoBibItem::BibItemType readonly
Instance Method Summary collapse
-
#initialize(**args) ⇒ BibliographicItem
constructor
A new instance of BibliographicItem.
- #to_xml ⇒ String
Constructor Details
#initialize(**args) ⇒ BibliographicItem
Returns a new instance of BibliographicItem.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 166 def initialize(**args) @id = args[:id] @title = (args[:titles] || []).map { |t| FormattedString.new t } @docidentifier = args[:docid] || [] @dates = (args[:dates] || []).map do |d| d.is_a?(Hash) ? BibliographicDate.new(d) : d end @contributors = (args[:contributors] || []).map do |c| if c.is_a? Hash e = c[:entity].is_a?(Hash) ? Organization.new(c[:entity]) : c[:entity] ContributionInfo.new(entity: e, role: c[:roles]) else c end end @notes = [] @language = args[:language] @script = args[:script] @status = args[:docstatus] @abstract = (args[:abstract] || []).map do |a| a.is_a?(Hash) ? FormattedString.new(a) : a end @relations = DocRelationCollection.new(args[:relations] || []) @link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s } @series = args[:series] end |
Instance Attribute Details
#abstract(lang: nil) ⇒ IsoBibItem::FormattedString+ (readonly)
|
# File 'lib/iso_bib_item/bibliographic_item.rb', line 135
|
#contributors ⇒ Array<IsoBibItem::ContributionInfo> (readonly)
118 119 120 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 118 def contributors @contributors end |
#copyright ⇒ IsoBibItem::CopyrightAssociation (readonly)
142 143 144 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 142 def copyright @copyright end |
#dates ⇒ Array<IsoBibItem::BibliographicDate> (readonly)
115 116 117 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 115 def dates @dates end |
#docidentifier ⇒ Array<IsoBibItem::DocumentIdentifier> (readonly)
112 113 114 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 112 def docidentifier @docidentifier end |
#edition ⇒ String (readonly)
121 122 123 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 121 def edition @edition end |
#formatted_ref ⇒ IsoBibItem::FormattedString (readonly)
133 134 135 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 133 def formatted_ref @formatted_ref end |
#id ⇒ String (readonly)
100 101 102 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 100 def id @id end |
#language ⇒ Array<String> (readonly)
Returns language Iso639 code.
127 128 129 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 127 def language @language end |
#link ⇒ Array<IsoBibItem::TypedUri> (readonly)
106 107 108 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 106 def link @link end |
#notes ⇒ Array<IsoBibItem::FormattedString> (readonly)
124 125 126 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 124 def notes @notes end |
#relations ⇒ IsoBibItem::DocRelationCollection (readonly)
145 146 147 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 145 def relations @relations end |
#script ⇒ Array<String> (readonly)
Returns script Iso15924 code.
130 131 132 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 130 def script @script end |
#series ⇒ Array<IsoBibItem::Series> (readonly)
148 149 150 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 148 def series @series end |
#status ⇒ IsoBibItem::DocumentStatus (readonly)
139 140 141 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 139 def status @status end |
#title ⇒ Array<IsoBibItem::FormattedString> (readonly)
103 104 105 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 103 def title @title end |
#type ⇒ IsoBibItem::BibItemType (readonly)
109 110 111 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 109 def type @type end |
Instance Method Details
#to_xml ⇒ String
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/iso_bib_item/bibliographic_item.rb', line 207 def to_xml Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.bibitem(id: id) do title.each { |t| xml.title { t.to_xml xml } } link.each { |s| s.to_xml xml } docidentifier.each { |di| di.to_xml xml } dates.each { |d| d.to_xml xml } contributors.each do |c| xml.contributor do c.role.each { |r| r.to_xml xml } c.to_xml xml end end language.each { |l| xml.language l } status&.to_xml xml series.each { |s| s.to_xml xml } if series end end.doc.root.to_xml end |