Class: Try::Success

Inherits:
Trither::Box show all
Includes:
Trither::BasicTypes
Defined in:
lib/trither/try.rb,
lib/trither/try.rb

Constant Summary

Constants included from Trither::BasicTypes

Trither::BasicTypes::C, Trither::BasicTypes::Func0, Trither::BasicTypes::Func1, Trither::BasicTypes::Predicate

Constants inherited from Trither::Box

Trither::Box::C

Instance Method Summary collapse

Methods inherited from Trither::Box

#==, #initialize

Constructor Details

This class inherits a constructor from Trither::Box

Instance Method Details

#fail_mapObject



87
88
89
# File 'lib/trither/try.rb', line 87

def fail_map
  self
end

#failure?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/trither/try.rb', line 67

def failure?
  false
end

#filterObject



72
73
74
# File 'lib/trither/try.rb', line 72

def filter
  yield(@value) ? self : Failure.new(Option::None)
end

#flat_map {|@value| ... } ⇒ Object

Yields:

  • (@value)


77
78
79
# File 'lib/trither/try.rb', line 77

def flat_map
  yield @value
end

#get_or_elseObject



97
98
99
# File 'lib/trither/try.rb', line 97

def get_or_else
  @value
end

#mapObject



82
83
84
# File 'lib/trither/try.rb', line 82

def map
  Success.new yield(@value)
end

#or_elseObject



92
93
94
# File 'lib/trither/try.rb', line 92

def or_else
  self
end