Class: Verbalize::Result
- Inherits:
-
Object
- Object
- Verbalize::Result
- Defined in:
- lib/verbalize/result.rb
Instance Attribute Summary collapse
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
Instance Method Summary collapse
- #failed? ⇒ Boolean (also: #failure?)
-
#initialize(outcome:, value:) ⇒ Result
constructor
A new instance of Result.
- #succeeded? ⇒ Boolean (also: #success?)
- #to_ary ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(outcome:, value:) ⇒ Result
Returns a new instance of Result.
3 4 5 6 |
# File 'lib/verbalize/result.rb', line 3 def initialize(outcome:, value:) @outcome = outcome @value = value end |
Instance Attribute Details
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
8 9 10 |
# File 'lib/verbalize/result.rb', line 8 def outcome @outcome end |
Instance Method Details
#failed? ⇒ Boolean Also known as: failure?
15 16 17 |
# File 'lib/verbalize/result.rb', line 15 def failed? outcome == :error end |
#succeeded? ⇒ Boolean Also known as: success?
10 11 12 |
# File 'lib/verbalize/result.rb', line 10 def succeeded? !failed? end |
#to_ary ⇒ Object
20 21 22 |
# File 'lib/verbalize/result.rb', line 20 def to_ary [outcome, @value] end |
#value ⇒ Object
24 25 26 |
# File 'lib/verbalize/result.rb', line 24 def value raise NotImplementedError, 'Subclasses must override Verbalize::Result#value' end |