Class: BibliographicalImporter::BibTex::Reader
- Inherits:
-
Object
- Object
- BibliographicalImporter::BibTex::Reader
- Includes:
- AbstractReader, Enumerable
- Defined in:
- lib/bibliographical_importer/bibtex.rb
Instance Attribute Summary collapse
-
#bb ⇒ Object
readonly
Returns the value of attribute bb.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Class Method Summary collapse
-
.fix_string(string) ⇒ Object
deprecated
Deprecated.
for bibtex-ruby>=4.4.5
- .open(filename) ⇒ Object
-
.parse(string, bib_db = nil) ⇒ Object
Parse a BibTex file.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(bibtex_bibliography) ⇒ Reader
constructor
A new instance of Reader.
- #parse_records ⇒ Object
Constructor Details
#initialize(bibtex_bibliography) ⇒ Reader
Returns a new instance of Reader
214 215 216 217 |
# File 'lib/bibliographical_importer/bibtex.rb', line 214 def initialize(bibtex_bibliography) @bb=bibtex_bibliography parse_records end |
Instance Attribute Details
#bb ⇒ Object (readonly)
Returns the value of attribute bb
208 209 210 |
# File 'lib/bibliographical_importer/bibtex.rb', line 208 def bb @bb end |
#records ⇒ Object (readonly)
Returns the value of attribute records
209 210 211 |
# File 'lib/bibliographical_importer/bibtex.rb', line 209 def records @records end |
Class Method Details
.fix_string(string) ⇒ Object
Deprecated.
for bibtex-ruby>=4.4.5
If ID for a bibtex contains a single quote, class just fail This method just delete the quote, until Bibtex class fix it
226 227 228 229 230 231 232 233 234 |
# File 'lib/bibliographical_importer/bibtex.rb', line 226 def self.fix_string(string) string.each_line.map { |line| if line=~/^\s*\@.+\{(.+),$/ line.gsub("'","") else line end }.join("\n") end |
.open(filename) ⇒ Object
219 220 221 222 |
# File 'lib/bibliographical_importer/bibtex.rb', line 219 def self.open(filename) b=BibTeX.open(filename, :strip => false) Reader.new(b) end |
.parse(string, bib_db = nil) ⇒ Object
Parse a BibTex file
239 240 241 242 243 244 245 |
# File 'lib/bibliographical_importer/bibtex.rb', line 239 def self.parse(string, bib_db=nil) @bib_db=bib_db # Scopus generates bibtex with quotes on names. That brokes Bibtex package #string_fixed=fix_string(string) b=BibTeX.parse(string, :strip => false) Reader.new(b) end |
Instance Method Details
#each(&block) ⇒ Object
210 211 212 |
# File 'lib/bibliographical_importer/bibtex.rb', line 210 def each(&block) @records.each(&block) end |