Class: RelatonBib::LocalityStack

Inherits:
Object
  • Object
show all
Includes:
RelatonBib
Defined in:
lib/relaton_bib/bib_item_locality.rb

Direct Known Subclasses

SourceLocalityStack

Constant Summary

Constants included from RelatonBib

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RelatonBib

array, format_date, grammar_hash, parse_date, parse_yaml

Constructor Details

#initialize(locality) ⇒ LocalityStack



108
109
110
# File 'lib/relaton_bib/bib_item_locality.rb', line 108

def initialize(locality)
  @locality = locality
end

Instance Attribute Details

#localityArray<RelatonBib::Locality> (readonly)



105
106
107
# File 'lib/relaton_bib/bib_item_locality.rb', line 105

def locality
  @locality
end

Instance Method Details

#to_asciibib(prefix = "", size = 1) ⇒ String

Render locality stack as AsciiBib.



132
133
134
135
136
137
# File 'lib/relaton_bib/bib_item_locality.rb', line 132

def to_asciibib(prefix = "", size = 1)
  pref = prefix.empty? ? "locality_stack" : "#{prefix}.locality_stack"
  out = ""
  out << "#{pref}::\n" if size > 1
  out << locality.map { |l| l.to_asciibib(pref, locality.size) }.join
end

#to_bibtex(item) ⇒ Object

Render locality stack as BibTeX.



144
145
146
# File 'lib/relaton_bib/bib_item_locality.rb', line 144

def to_bibtex(item)
  locality.each { |l| l.to_bibtex(item) }
end

#to_hashObject



120
121
122
# File 'lib/relaton_bib/bib_item_locality.rb', line 120

def to_hash
  { "locality_stack" => single_element_array(locality) }
end

#to_xml(builder) ⇒ Object



113
114
115
116
117
# File 'lib/relaton_bib/bib_item_locality.rb', line 113

def to_xml(builder)
  builder.localityStack do |b|
    locality.each { |l| l.to_xml(b) }
  end
end