Module: Chitin::Runnable
- Included in:
- Executable, PVC, Pipe
- Defined in:
- lib/chitin/commands/runnable.rb
Instance Method Summary collapse
- #<(io) ⇒ Object
- #>(io) ⇒ Object
- #>>(io) ⇒ Object
-
#[](*args) ⇒ Object
access private methods.
- #^(io) ⇒ Object
- #bg! ⇒ Object
- #bg? ⇒ Boolean
- #fg? ⇒ Boolean
- #initialize ⇒ Object
- #|(other) ⇒ Object (also: #<=>)
Instance Method Details
#<(io) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chitin/commands/runnable.rb', line 10 def <(io) case io when IO, File self[:set_in, io] when String, FileObject f = File.open io.to_s, 'r' self[:set_in, f] f.close else raise "Unknown piping type: #{io.class}" end self end |
#>(io) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chitin/commands/runnable.rb', line 25 def >(io) case io when IO, File self[:set_out, io] when String, FileObject f = File.open io.to_s, 'w' self[:set_out, f] f.close else raise "Unknown piping type: #{io.class}" end self end |
#>>(io) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chitin/commands/runnable.rb', line 40 def >>(io) case io when IO, File self[:set_out, io] when String, FileObject f = File.open io.to_s, 'a' self[:set_out, f] f.close else raise "Unknown piping type: #{io.class}" end self end |
#[](*args) ⇒ Object
access private methods
71 72 73 74 75 76 77 78 |
# File 'lib/chitin/commands/runnable.rb', line 71 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 |
#^(io) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chitin/commands/runnable.rb', line 55 def ^(io) case io when IO, File self[:set_err, io] when String, FileObject f = File.open io.to_s, 'w' self[:set_err, f] f.close else raise "Unknown piping type: #{io.class}" end self end |
#bg! ⇒ Object
80 |
# File 'lib/chitin/commands/runnable.rb', line 80 def bg!; @bg = true; self; end |
#bg? ⇒ Boolean
81 |
# File 'lib/chitin/commands/runnable.rb', line 81 def bg?; @bg; end |
#fg? ⇒ Boolean
82 |
# File 'lib/chitin/commands/runnable.rb', line 82 def fg?; !@bg; end |
#initialize ⇒ Object
4 5 6 7 8 |
# File 'lib/chitin/commands/runnable.rb', line 4 def initialize set_in STDIN set_out STDOUT set_err STDERR end |