Module: Chitin::Runnable

Included in:
Executable, Pipe, StringMethod, Proc
Defined in:
lib/chitin/commands/runnable.rb

Instance Method Summary collapse

Instance Method Details

#>(io) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/chitin/commands/runnable.rb', line 4

def >(io)
  case io
  when IO, File
    self[:set_out, io]
  when String, FileObject
    f = File.open io, 'w'
    self[:set_out, f]
    f.close
  else
    raise "Unknown piping type: #{io.class}"
  end
  
  self
end

#[](*args) ⇒ Object

access private methods



20
21
22
23
24
25
26
27
# File 'lib/chitin/commands/runnable.rb', line 20

def [](*args)
  if method(args.first)
    method(args.first).call *args[1..-1]
  else
    raise NoMethodError.new("undefined method" +
                            "`#{args.first}' for #{self}:#{self.class}")
  end
end