Module: Rumonade

Defined in:
lib/rumonade.rb,
lib/rumonade/hash.rb,
lib/rumonade/array.rb,
lib/rumonade/monad.rb,
lib/rumonade/either.rb,
lib/rumonade/errors.rb,
lib/rumonade/option.rb,
lib/rumonade/version.rb,
lib/rumonade/error_handling.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ArrayExtensions, ErrorHandling, HashExtensions, Monad Classes: Either, Left, NoSuchElementError, NoneClass, Option, PartialFunction, Right, Some

Constant Summary collapse

None =

The single global instance of NoneClass, representing the empty Option

NoneClass.instance
VERSION =
"0.4.4"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.Left(left_value) ⇒ Left

Parameters:

  • left_value

    the value to store in a Left, usually representing a failure result

Returns:



149
150
151
# File 'lib/rumonade/either.rb', line 149

def Left(left_value)
  Left.new(left_value)
end

.Option(value) ⇒ Object

Returns an Option wrapping the given value: Some if non-nil, None if nil



127
128
129
# File 'lib/rumonade/option.rb', line 127

def Option(value)
  value.nil? ? None : Some(value)
end

.Right(right_value) ⇒ Right

Parameters:

  • right_value

    the value to store in a Right, usually representing a success result

Returns:



155
156
157
# File 'lib/rumonade/either.rb', line 155

def Right(right_value)
  Right.new(right_value)
end

.Some(value) ⇒ Some

Returns a Some wrapping the given value, for convenience

Returns:

  • (Some)

    Returns a Some wrapping the given value, for convenience



132
133
134
# File 'lib/rumonade/option.rb', line 132

def Some(value)
  Some.new(value)
end

Instance Method Details

#Left(left_value) ⇒ Left

Parameters:

  • left_value

    the value to store in a Left, usually representing a failure result

Returns:



149
150
151
# File 'lib/rumonade/either.rb', line 149

def Left(left_value)
  Left.new(left_value)
end

#Option(value) ⇒ Object

Returns an Option wrapping the given value: Some if non-nil, None if nil



127
128
129
# File 'lib/rumonade/option.rb', line 127

def Option(value)
  value.nil? ? None : Some(value)
end

#Right(right_value) ⇒ Right

Parameters:

  • right_value

    the value to store in a Right, usually representing a success result

Returns:



155
156
157
# File 'lib/rumonade/either.rb', line 155

def Right(right_value)
  Right.new(right_value)
end

#Some(value) ⇒ Some

Returns a Some wrapping the given value, for convenience

Returns:

  • (Some)

    Returns a Some wrapping the given value, for convenience



132
133
134
# File 'lib/rumonade/option.rb', line 132

def Some(value)
  Some.new(value)
end