Class: Rundoc::CodeCommand::Background::StdinWrite
- Inherits:
-
Rundoc::CodeCommand
- Object
- Rundoc::CodeCommand
- Rundoc::CodeCommand::Background::StdinWrite
- Defined in:
- lib/rundoc/code_command/background/stdin_write.rb
Overview
Will send contents to the background process via STDIN along with a newline
Constant Summary
Constants inherited from Rundoc::CodeCommand
NEWLINE, RUNDOC_DEFAULT_ERB_BINDING, RUNDOC_ERB_BINDINGS
Instance Attribute Summary
Attributes inherited from Rundoc::CodeCommand
#command, #contents, #keyword, #original_args, #render_command, #render_result
Instance Method Summary collapse
-
#call(env = {}) ⇒ Object
The contents produced by the command (‘:::->`) are rendered by the `def to_md` method.
-
#initialize(contents, name:, wait:, timeout: 5, ending: $/) ⇒ StdinWrite
constructor
A new instance of StdinWrite.
-
#to_md(env = {}) ⇒ Object
The command is rendered (‘:::>-`) by the output of the `def call` method.
- #writecontents ⇒ Object
Methods inherited from Rundoc::CodeCommand
Constructor Details
#initialize(contents, name:, wait:, timeout: 5, ending: $/) ⇒ StdinWrite
Returns a new instance of StdinWrite.
6 7 8 9 10 11 12 13 |
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 6 def initialize(contents, name:, wait:, timeout: 5, ending: $/) @contents = contents @ending = ending @spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name) @wait = wait @timeout_value = Integer(timeout) @contents_written = nil end |
Instance Method Details
#call(env = {}) ⇒ Object
The contents produced by the command (‘:::->`) are rendered by the `def to_md` method.
21 22 23 24 |
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 21 def call(env = {}) writecontents @spawn.log.read end |
#to_md(env = {}) ⇒ Object
The command is rendered (‘:::>-`) by the output of the `def call` method.
16 17 18 |
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 16 def to_md(env = {}) writecontents end |
#writecontents ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/rundoc/code_command/background/stdin_write.rb', line 26 def writecontents @contents_written ||= @spawn.stdin_write( contents, wait: @wait, ending: @ending, timeout: @timeout_value ) end |