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
Constructor Details
#initialize(locality) ⇒ LocalityStack
Returns a new instance of LocalityStack.
108 109 110 |
# File 'lib/relaton_bib/bib_item_locality.rb', line 108 def initialize(locality) @locality = locality end |
Instance Attribute Details
#locality ⇒ Array<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_hash ⇒ Object
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 |