Class: Rundoc::CodeCommand::PrintTextRunner
- Inherits:
-
Object
- Object
- Rundoc::CodeCommand::PrintTextRunner
- Defined in:
- lib/rundoc/code_command/print/text.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Instance Method Summary collapse
- #call(env = {}) ⇒ Object
-
#initialize(user_args:, render_command:, render_result:, io: nil, contents: nil) ⇒ PrintTextRunner
constructor
A new instance of PrintTextRunner.
- #render_before? ⇒ Boolean
- #render_command? ⇒ Boolean
- #render_result? ⇒ Boolean
- #to_md(env) ⇒ Object
Constructor Details
#initialize(user_args:, render_command:, render_result:, io: nil, contents: nil) ⇒ PrintTextRunner
Returns a new instance of PrintTextRunner.
15 16 17 18 19 20 |
# File 'lib/rundoc/code_command/print/text.rb', line 15 def initialize(user_args:, render_command:, render_result:, io: nil, contents: nil) @line = user_args.line @render_command = render_command @render_result = render_result @contents = contents.dup if contents && !contents.empty? end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
13 14 15 |
# File 'lib/rundoc/code_command/print/text.rb', line 13 def contents @contents end |
Instance Method Details
#call(env = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/rundoc/code_command/print/text.rb', line 38 def call(env = {}) if render_before? "" else [@line, contents].compact.join("\n") end end |
#render_before? ⇒ Boolean
46 47 48 |
# File 'lib/rundoc/code_command/print/text.rb', line 46 def render_before? !render_command? && render_result? end |
#render_command? ⇒ Boolean
22 23 24 |
# File 'lib/rundoc/code_command/print/text.rb', line 22 def render_command? @render_command end |
#render_result? ⇒ Boolean
26 27 28 |
# File 'lib/rundoc/code_command/print/text.rb', line 26 def render_result? @render_result end |
#to_md(env) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rundoc/code_command/print/text.rb', line 30 def to_md(env) if render_before? env[:before] << [@line, contents].compact.join("\n") end "" end |