Class: MultiMarkdownCLI::Parser
- Inherits:
-
Object
- Object
- MultiMarkdownCLI::Parser
- Defined in:
- lib/multimarkdown-cli.rb
Instance Attribute Summary collapse
-
#compatibility ⇒ Object
Returns the value of attribute compatibility.
-
#snippet ⇒ Object
Returns the value of attribute snippet.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #convert(format) ⇒ Object
-
#initialize(source, *options) ⇒ Parser
constructor
A new instance of Parser.
- #to_html ⇒ Object
Constructor Details
#initialize(source, *options) ⇒ Parser
Returns a new instance of Parser.
34 35 36 37 38 39 40 |
# File 'lib/multimarkdown-cli.rb', line 34 def initialize(source, *) @source = source @compatibility = false @snippet = false .each {|o| send("#{o}=", true)} end |
Instance Attribute Details
#compatibility ⇒ Object
Returns the value of attribute compatibility.
30 31 32 |
# File 'lib/multimarkdown-cli.rb', line 30 def compatibility @compatibility end |
#snippet ⇒ Object
Returns the value of attribute snippet.
32 33 34 |
# File 'lib/multimarkdown-cli.rb', line 32 def snippet @snippet end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
28 29 30 |
# File 'lib/multimarkdown-cli.rb', line 28 def source @source end |
Instance Method Details
#convert(format) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/multimarkdown-cli.rb', line 41 def convert(format) cmd = "multimarkdown" cmd += " -c" if @compatibility cmd += " -s" if @snippet require 'open3' stdout, stderr, status = Open3.capture3("#{cmd} -t #{format}", :stdin_data=>@source) if status.exitstatus != 0 raise stderr end stdout end |
#to_html ⇒ Object
53 54 55 |
# File 'lib/multimarkdown-cli.rb', line 53 def to_html self.convert("html") end |