Class: Docdown::CodeCommands::Repl

Inherits:
Docdown::CodeCommand show all
Defined in:
lib/docdown/code_commands/repl.rb

Instance Attribute Summary

Attributes inherited from Docdown::CodeCommand

#command, #contents, #hidden, #keyword, #render_result

Instance Method Summary collapse

Methods inherited from Docdown::CodeCommand

#push, #render

Constructor Details

#initialize(command) ⇒ Repl

Returns a new instance of Repl.



6
7
8
9
# File 'lib/docdown/code_commands/repl.rb', line 6

def initialize(command)
  @command     = command
  @contents = ""
end

Instance Method Details

#callObject



23
24
25
26
27
# File 'lib/docdown/code_commands/repl.rb', line 23

def call
  puts @contents.inspect
  zip = ReplRunner.new(:"#{keyword}", @command).zip(contents.strip)
  @result = zip.flatten.join("\n")
end

#keyword=(keyword) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/docdown/code_commands/repl.rb', line 11

def keyword=(keyword)
  @keyword = keyword
  puts keyword
  if keyword.to_s == "repl"
    command_array = @command.split(" ")
    puts command_array.inspect
    @keyword      = command_array.first
  else
    @command = "#{keyword} #{@command}"
  end
end

#to_mdObject



29
30
31
# File 'lib/docdown/code_commands/repl.rb', line 29

def to_md
  "$ #{@command}"
end