Class: Bibkeys
- Inherits:
-
Object
- Object
- Bibkeys
- Defined in:
- lib/bibkeys.rb,
lib/bibkeys/version.rb
Overview
This class parses a stream of BibTeX input passed to it and provides a method to list its keys, sorted or unsorted.
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
-
#initialize(stream, sort = false) ⇒ Bibkeys
constructor
Parses an input stream as if it were a BibTeX file.
-
#list ⇒ Object
List all the keys in the BibTeX file.
Constructor Details
#initialize(stream, sort = false) ⇒ Bibkeys
Parses an input stream as if it were a BibTeX file
14 15 16 17 |
# File 'lib/bibkeys.rb', line 14 def initialize ( stream , sort=false ) @bib = BibTeX.parse( stream ) @sort = sort end |
Instance Method Details
#list ⇒ Object
List all the keys in the BibTeX file
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bibkeys.rb', line 21 def list keys = Array.new @bib.each do |entry| keys.push entry.key end if @sort puts keys.sort else puts keys end end |