class Script2md::Fill

Attributes

script[RW]
text[RW]

Public Class Methods

new(text, script: nil) click to toggle source
# File lib/script2md.rb, line 52
def initialize(text, script: nil)
  @text = text
  @script = script
end

Public Instance Methods

convert() click to toggle source
# File lib/script2md.rb, line 59
def convert
  fill_command_output!
  self
end

Private Instance Methods

fill_command_output!() click to toggle source
# File lib/script2md.rb, line 69
def fill_command_output!
  output = ''
  text.each_line do |line|
    if line.chomp == '!OUTPUT!'
      File.write('./tmpscript', script)
      File.chmod(0700, './tmpscript')
      output += "```\n" + `./tmpscript` + "```\n"
      File.delete('./tmpscript')
    else
      output += line
    end
  end

  self.text = output
end