Class: Tzu::Outcome
- Inherits:
-
Object
- Object
- Tzu::Outcome
- Defined in:
- lib/tzu/outcome.rb
Overview
The result of executing a command
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #failure? ⇒ Boolean
- #handle(context = nil, &block) ⇒ Object
-
#initialize(success, result, type = nil) ⇒ Outcome
constructor
A new instance of Outcome.
- #success? ⇒ Boolean
Constructor Details
#initialize(success, result, type = nil) ⇒ Outcome
Returns a new instance of Outcome.
6 7 8 9 10 |
# File 'lib/tzu/outcome.rb', line 6 def initialize(success, result, type = nil) @success = success @result = result @type = type end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/tzu/outcome.rb', line 4 def result @result end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
4 5 6 |
# File 'lib/tzu/outcome.rb', line 4 def success @success end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/tzu/outcome.rb', line 4 def type @type end |
Instance Method Details
#failure? ⇒ Boolean
16 17 18 |
# File 'lib/tzu/outcome.rb', line 16 def failure? !@success end |
#handle(context = nil, &block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/tzu/outcome.rb', line 20 def handle(context=nil, &block) context ||= block.binding.eval('self') match = Match.new(self, context) match.instance_eval &block match.result end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/tzu/outcome.rb', line 12 def success? @success end |