class BibtexToScrapbox::Converter
Your code goes hereā¦
Public Class Methods
add(path)
click to toggle source
# File lib/bibtex_to_scrapbox.rb, line 8 def Converter.add(path) @@converters.push Converter.new(path) end
new(path)
click to toggle source
# File lib/bibtex_to_scrapbox.rb, line 26 def initialize(path) @bibtex_path=File.expand_path(path) @bib=BibTeX.open(@bibtex_path) end
perform()
click to toggle source
# File lib/bibtex_to_scrapbox.rb, line 12 def Converter.perform() pages=[] @@converters.map do |converter| pages.concat converter.start() end result={ "pages": pages } puts result.to_json end
Public Instance Methods
start()
click to toggle source
# 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