Class: Rundoc::CodeCommand::Pipe

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

Instance Attribute Summary

Attributes inherited from Rundoc::CodeCommand

#command, #contents, #hidden, #keyword, #render_result

Instance Method Summary collapse

Methods inherited from Rundoc::CodeCommand

#not_hidden?, #push

Constructor Details

#initialize(line) ⇒ Pipe

:

ls

:

| tail -n 2

> “testntmp.filen”



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

def initialize(line)
  line_array = line.split(" ")
  @first     = line_array.shift.strip
  @delegate  = Rundoc.code_command_from_keyword(@first, line_array.join(" "))
  @delegate  = Rundoc::CodeCommand::Bash.new(line) if @delegate.kind_of?(Rundoc::CodeCommand::NoSuchCommand)
end

Instance Method Details

#call(env = {}) ⇒ Object

before: “”, after: “”, commands:

[[cmd, output], [cmd, output]]


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

def call(env = {})
  last_command = env[:commands].last
  puts "Piping: results of '#{last_command[:command]}' to '#{@delegate}'"

  @delegate.push(last_command[:output])
  @delegate.call(env)
end

#to_md(env = {}) ⇒ Object



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

def to_md(env = {})
  ""
end