Class: StubShell::Command
- Inherits:
-
Object
- Object
- StubShell::Command
- Defined in:
- lib/stub_shell/command.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #current_context ⇒ Object
- #exitstatus(code) ⇒ Object
-
#initialize(match, context, &block) ⇒ Command
constructor
A new instance of Command.
- #matches?(input_string) ⇒ Boolean
- #stderr(output) ⇒ Object
- #stdout(output) ⇒ Object
- #stub_shell(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/stub_shell/command.rb', line 3 def context @context end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
3 4 5 |
# File 'lib/stub_shell/command.rb', line 3 def match @match end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/stub_shell/command.rb', line 3 def result @result end |
Instance Method Details
#current_context ⇒ Object
27 28 29 |
# File 'lib/stub_shell/command.rb', line 27 def current_context @stub_shell end |
#exitstatus(code) ⇒ Object
39 40 41 |
# File 'lib/stub_shell/command.rb', line 39 def exitstatus code result.exitstatus = code end |
#matches?(input_string) ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'lib/stub_shell/command.rb', line 18 def matches? input_string case match when String input_string == match when Regexp !!(match.match input_string) end end |
#stderr(output) ⇒ Object
35 36 37 |
# File 'lib/stub_shell/command.rb', line 35 def stderr output result.stderr = output end |
#stdout(output) ⇒ Object
31 32 33 |
# File 'lib/stub_shell/command.rb', line 31 def stdout output result.stdout = output end |