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

Methods included from Config

#configuration, #configure

Constructor Details

#initialize(locality) ⇒ LocalityStack

Returns a new instance of LocalityStack.

Parameters:



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

def initialize(locality)
  @locality = locality
end

Instance Attribute Details

#localityArray<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.

Parameters:

  • prefix (String) (defaults to: "")

    <description>

  • size (Integer) (defaults to: 1)

    size of locality stack

Returns:

  • (String)

    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.

Parameters:

  • item (BibTeX::Entry)

    BibTeX entry.



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_hashObject



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

Parameters:

  • builder (Nokogiri::XML::Builder)


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