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, parse_date, parse_yaml

Constructor Details

#initialize(locality) ⇒ LocalityStack

Returns a new instance of LocalityStack.

Parameters:



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.

Parameters:

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

    <description>

  • size (Integer) (defaults to: 1)

    size of locality stack

Returns:

  • (String)

    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.

Parameters:

  • item (BibTeX::Entry)

    BibTeX entry.



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

Parameters:

  • builder (Nokogiri::XML::Builder)


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