-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update exten, localyty, & move flavor attr to ext in YAML
- Loading branch information
1 parent
3b7826c
commit 96f449a
Showing
20 changed files
with
362 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module RelatonBib | ||
class Extent | ||
attr_accessor :locality | ||
|
||
# | ||
# @param [Array<RelatonBib::Locality, RelatonBib::LocalityStack>] locality | ||
# | ||
def initialize(locality) | ||
@locality = locality | ||
end | ||
|
||
def to_xml(builder) | ||
builder.extent do |b| | ||
locality.each { |l| l.to_xml(b) } | ||
end | ||
end | ||
|
||
def to_hash | ||
hash = Hash.new { |h, k| h[k] = [] } | ||
locality.each_with_object(hash) do |l, obj| | ||
k, v = l.to_hash.first | ||
obj[k] << v | ||
end | ||
end | ||
|
||
def to_asciibib(prefix = "", count = 1) | ||
pref = prefix.empty? ? "extent" : "#{prefix}.extent" | ||
out = count > 1 ? "#{pref}::\n" : "" | ||
locality.each do |l| | ||
out += l.to_asciibib(pref, locality.size) | ||
end | ||
out | ||
end | ||
|
||
def to_bibtex(item) | ||
locality.map { |l| l.to_bibtex(item) }.join | ||
end | ||
end | ||
end |
Oops, something went wrong.