Class: Bibkeys

Inherits:
Object
  • Object
show all
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

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

#listObject

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