Class: Rundoc::CodeCommand::PrintText

Inherits:
Rundoc::CodeCommand show all
Defined in:
lib/rundoc/code_command/print/text.rb

Constant Summary

Constants inherited from Rundoc::CodeCommand

NEWLINE

Instance Attribute Summary

Attributes inherited from Rundoc::CodeCommand

#command, #contents, #keyword, #original_args, #render_command, #render_result

Instance Method Summary collapse

Methods inherited from Rundoc::CodeCommand

#not_hidden?, #push

Constructor Details

#initialize(line) ⇒ PrintText

Returns a new instance of PrintText.



3
4
5
# File 'lib/rundoc/code_command/print/text.rb', line 3

def initialize(line)
  @line = line
end

Instance Method Details

#call(env = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rundoc/code_command/print/text.rb', line 19

def call(env = {})
  if render_before?
    ""
  else
    [@line, contents].compact.join("\n")
  end
end

#hidden?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rundoc/code_command/print/text.rb', line 15

def hidden?
  !render_result?
end

#render_before?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rundoc/code_command/print/text.rb', line 27

def render_before?
  !render_command? && render_result?
end

#to_md(env) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/rundoc/code_command/print/text.rb', line 7

def to_md(env)
  if render_before?
    env[:before] << [@line, contents].compact.join("\n")
  end

  ""
end