Class: Rundoc::CodeCommand::Background::StdinWriteRunner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of StdinWriteRunner.



19
20
21
22
23
24
25
26
27
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 19

def initialize(user_args:, render_command:, render_result:, io: nil, contents: nil)
  @contents = user_args.contents
  @ending = user_args.ending
  @wait = user_args.wait
  @name = user_args.name
  @timeout_value = user_args.timeout
  @contents_written = nil
  @background = nil
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



17
18
19
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 17

def contents
  @contents
end

Instance Method Details

#backgroundObject



29
30
31
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 29

def background
  @background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(@name)
end

#call(env = {}) ⇒ Object

The contents produced by the command (‘:::->`) are rendered by the `def to_md` method.



39
40
41
42
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 39

def call(env = {})
  writecontents
  background.log.read
end

#to_md(env = {}) ⇒ Object

The command is rendered (‘:::>-`) by the output of the `def call` method.



34
35
36
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 34

def to_md(env = {})
  writecontents
end

#writecontentsObject



44
45
46
47
48
49
50
51
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 44

def writecontents
  @contents_written ||= background.stdin_write(
    contents,
    wait: @wait,
    ending: @ending,
    timeout: @timeout_value
  )
end