Module: Coque::Redirectable

Included in:
Cmd, Pipeline
Defined in:
lib/coque/redirectable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stderrObject

Returns the value of attribute stderr.



5
6
7
# File 'lib/coque/redirectable.rb', line 5

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



5
6
7
# File 'lib/coque/redirectable.rb', line 5

def stdin
  @stdin
end

#stdoutObject

Returns the value of attribute stdout.



5
6
7
# File 'lib/coque/redirectable.rb', line 5

def stdout
  @stdout
end

Instance Method Details

#<(io) ⇒ Object



13
14
15
16
17
# File 'lib/coque/redirectable.rb', line 13

def <(io)
  clone.tap do |c|
    c.stdin = io
  end
end

#>(io) ⇒ Object



7
8
9
10
11
# File 'lib/coque/redirectable.rb', line 7

def >(io)
  clone.tap do |c|
    c.stdout = io
  end
end

#>=(io) ⇒ Object



19
20
21
22
23
# File 'lib/coque/redirectable.rb', line 19

def >=(io)
  clone.tap do |c|
    c.stderr = io
  end
end

#getio(io, mode = "r") ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/coque/redirectable.rb', line 25

def getio(io, mode = "r")
  case io
  when String
    File.open(io, mode)
  when Pathname
    File.open(io, mode)
  when IO
    io
  when Tempfile
    io
  else
    raise ArgumentError.new("Can't redirect stream to #{io}, must be String, Pathname, or IO")
  end
end

#to_aObject



52
53
54
# File 'lib/coque/redirectable.rb', line 52

def to_a
  run.to_a
end