Class: RelatonBib::Extent
Instance Attribute Summary collapse
-
#locality ⇒ Object
Returns the value of attribute locality.
Instance Method Summary collapse
-
#initialize(locality) ⇒ Extent
constructor
A new instance of Extent.
- #to_asciibib(prefix = "", count = 1) ⇒ Object
- #to_bibtex(item) ⇒ Object
- #to_hash ⇒ Object
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(locality) ⇒ Extent
Returns a new instance of Extent.
8 9 10 |
# File 'lib/relaton_bib/extent.rb', line 8 def initialize(locality) @locality = locality end |
Instance Attribute Details
#locality ⇒ Object
Returns the value of attribute locality.
3 4 5 |
# File 'lib/relaton_bib/extent.rb', line 3 def locality @locality end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/relaton_bib/extent.rb', line 26 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? "extent" : "#{prefix}.extent" out = count > 1 ? "#{pref}::\n" : "" locality.each do |l| out += l.to_asciibib(pref, locality.size) end out end |
#to_bibtex(item) ⇒ Object
35 36 37 |
# File 'lib/relaton_bib/extent.rb', line 35 def to_bibtex(item) locality.map { |l| l.to_bibtex(item) }.join end |
#to_hash ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/relaton_bib/extent.rb', line 18 def to_hash hash = Hash.new { |h, k| h[k] = [] } locality.each_with_object(hash) do |l, obj| k, v = l.to_hash.first obj[k] << v end end |
#to_xml(builder) ⇒ Object
12 13 14 15 16 |
# File 'lib/relaton_bib/extent.rb', line 12 def to_xml(builder) builder.extent do |b| locality.each { |l| l.to_xml(b) } end end |