Class: PandocRuby
- Inherits:
-
Object
- Object
- PandocRuby
- Defined in:
- lib/pandoc-ruby.rb
Constant Summary collapse
- EXECUTABLES =
%W[ pandoc markdown2pdf html2markdown hsmarkdown ]
- READERS =
{ 'rst' => 'reStructuredText', 'markdown' => 'markdown', 'html' => 'HTML', 'latex' => 'LaTeX' }
- WRITERS =
{ 'markdown' => 'markdown', 'rst' => 'reStructuredText', 'html' => 'HTML', 'latex' => 'LaTeX', 'context' => 'ConTeXt', 'man' => 'groff man', 'mediawiki' => 'MediaWiki markup', 'texinfo' => 'GNU Texinfo', 'docbook' => 'DocBook XML', 'opendocument' => 'OpenDocument XML', 's5' => 'S5 HTML and javascript slide show', 'rtf' => 'rich text format' }
- @@bin_path =
nil- @@allow_file_paths =
false
Class Method Summary collapse
Instance Method Summary collapse
- #convert(*args) ⇒ Object (also: #to_s)
-
#initialize(*args) ⇒ PandocRuby
constructor
A new instance of PandocRuby.
Constructor Details
#initialize(*args) ⇒ PandocRuby
Returns a new instance of PandocRuby.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pandoc-ruby.rb', line 48 def initialize(*args) target = args.shift @target = if @@allow_file_paths && File.exists?(target) File.read(target) else target rescue target end @executable = EXECUTABLES.include?(args[0]) ? args.shift : 'pandoc' @options = args end |
Class Method Details
.allow_file_paths=(value) ⇒ Object
40 41 42 |
# File 'lib/pandoc-ruby.rb', line 40 def self.allow_file_paths=(value) @@allow_file_paths = value end |
.bin_path=(path) ⇒ Object
36 37 38 |
# File 'lib/pandoc-ruby.rb', line 36 def self.bin_path=(path) @@bin_path = path end |
.convert(*args) ⇒ Object
44 45 46 |
# File 'lib/pandoc-ruby.rb', line 44 def self.convert(*args) new(*args).convert end |
Instance Method Details
#convert(*args) ⇒ Object Also known as: to_s
59 60 61 62 |
# File 'lib/pandoc-ruby.rb', line 59 def convert(*args) executable = @@bin_path ? File.join(@@bin_path, @executable) : @executable execute executable + (args) end |