Class: Rundoc::CodeCommand::RundocCommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/rundoc/code_command/rundoc_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_args:, render_command:, render_result:, io:, contents: nil) ⇒ RundocCommandRunner

Returns a new instance of RundocCommandRunner.



16
17
18
19
20
# File 'lib/rundoc/code_command/rundoc_command.rb', line 16

def initialize(user_args:, render_command:, render_result:, io:, contents: nil)
  @io = io
  @contents = contents.dup if contents && !contents.empty?
  @contents = user_args.code + (@contents || +"")
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



14
15
16
# File 'lib/rundoc/code_command/rundoc_command.rb', line 14

def contents
  @contents
end

#ioObject (readonly)

Returns the value of attribute io.



14
15
16
# File 'lib/rundoc/code_command/rundoc_command.rb', line 14

def io
  @io
end

Instance Method Details

#call(env = {}) ⇒ Object



26
27
28
29
30
# File 'lib/rundoc/code_command/rundoc_command.rb', line 26

def call(env = {})
  io.puts "Running: #{contents}"
  eval(contents) # rubocop:disable Security/Eval
  ""
end

#to_md(env = {}) ⇒ Object



22
23
24
# File 'lib/rundoc/code_command/rundoc_command.rb', line 22

def to_md(env = {})
  ""
end