Class: BibtexToScrapbox::Converter
- Inherits:
-
Object
- Object
- BibtexToScrapbox::Converter
- Defined in:
- lib/bibtex_to_scrapbox.rb
Overview
Your code goes here…
Constant Summary collapse
- @@converters =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Converter
constructor
A new instance of Converter.
- #start ⇒ Object
Constructor Details
#initialize(path) ⇒ Converter
Returns a new instance of Converter.
26 27 28 29 |
# File 'lib/bibtex_to_scrapbox.rb', line 26 def initialize(path) @bibtex_path=File.(path) @bib=BibTeX.open(@bibtex_path) end |
Class Method Details
.add(path) ⇒ Object
8 9 10 |
# File 'lib/bibtex_to_scrapbox.rb', line 8 def Converter.add(path) @@converters.push Converter.new(path) end |
.start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bibtex_to_scrapbox.rb', line 12 def Converter.start() pages=[] @@converters.map do |converter| pages.concat converter.start() end result={ "pages": pages } puts result.to_json end |
Instance Method Details
#start ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bibtex_to_scrapbox.rb', line 31 def start() basename=File.basename(@bibtex_path) @bib.collect do |e| lines=SbPage.new() citekey=e.key lines.push_text(citekey) lines.push_text(e.to_s) lines.push_empty_text() lines.push_text("[bibtex]") lines.push_text("[#{basename}]") { "title": citekey, "lines": lines.json } end end |