Class: RelatonBib::LocalityStack
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/bib_item_locality.rb
Direct Known Subclasses
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(locality) ⇒ LocalityStack
constructor
A new instance of LocalityStack.
-
#to_asciibib(prefix = "", size = 1) ⇒ String
Render locality stack as AsciiBib.
-
#to_bibtex(item) ⇒ Object
Render locality stack as BibTeX.
- #to_hash ⇒ Object
- #to_xml(builder) ⇒ Object
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
Constructor Details
#initialize(locality) ⇒ LocalityStack
Returns a new instance of LocalityStack.
109 110 111 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 109 def initialize(locality) @locality = locality end |
Instance Attribute Details
#locality ⇒ Array<RelatonBib::Locality> (readonly)
106 107 108 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 106 def locality @locality end |
Instance Method Details
#to_asciibib(prefix = "", size = 1) ⇒ String
Render locality stack as AsciiBib.
133 134 135 136 137 138 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 133 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.
145 146 147 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 145 def to_bibtex(item) locality.each { |l| l.to_bibtex(item) } end |
#to_hash ⇒ Object
121 122 123 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 121 def to_hash { "locality_stack" => single_element_array(locality) } end |
#to_xml(builder) ⇒ Object
114 115 116 117 118 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 114 def to_xml(builder) builder.localityStack do |b| locality.each { |l| l.to_xml(b) } end end |