Class: Loom::Shell::CmdRedirect
- Inherits:
-
Object
- Object
- Loom::Shell::CmdRedirect
- Defined in:
- lib/loom/shell/cmd_wrapper.rb
Defined Under Namespace
Modules: Mode
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(word, fd: nil, mode: Mode::OUTPUT) ⇒ CmdRedirect
constructor
A new instance of CmdRedirect.
- #to_s ⇒ Object
Constructor Details
#initialize(word, fd: nil, mode: Mode::OUTPUT) ⇒ CmdRedirect
Returns a new instance of CmdRedirect.
126 127 128 129 130 |
# File 'lib/loom/shell/cmd_wrapper.rb', line 126 def initialize(word, fd: nil, mode: Mode::OUTPUT) @fd = fd @word = word @mode = mode end |
Class Method Details
.append_stdout(word) ⇒ Object
112 113 114 |
# File 'lib/loom/shell/cmd_wrapper.rb', line 112 def append_stdout(word) CmdRedirect.new(word, mode: Mode::APPEND) end |
Instance Method Details
#to_s ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/loom/shell/cmd_wrapper.rb', line 132 def to_s case @mode when Mode::INPUT "%s<%s" % [@fd, @word] when Mode::OUTPUT "%s>%s" % [@fd, @word] when Mode::APPEND "%s>>%s" % [@fd, @word] when Mode::OUTPUT_12 "&>%s" % [@word] when Mode::APPEND_12 "&>>%s" % [@word] else raise "invalid shell redirection mode: #{@mode}" end end |