Class: Rumonade::Right

Inherits:
Either
  • Object
show all
Defined in:
lib/rumonade/either.rb

Overview

The right side of the disjoint union, as opposed to the Left side.

Constant Summary

Constants inherited from Either

Either::DEFAULT_CONCAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Either

#+, #fold, #left, #left?, #lift, #lift_to_a, #right, #right?, #swap

Constructor Details

#initialize(right_value) ⇒ Right

Returns a new instance of Right.

Parameters:

  • right_value

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



124
125
126
# File 'lib/rumonade/either.rb', line 124

def initialize(right_value)
  @right_value = right_value
end

Instance Attribute Details

#right_valueObject (readonly)

Returns the right value

Returns:

  • Returns the right value



129
130
131
# File 'lib/rumonade/either.rb', line 129

def right_value
  @right_value
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true if other is a Right with an equal right value

Returns:

  • (Boolean)

    Returns true if other is a Right with an equal right value



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

def ==(other)
  other.is_a?(Right) && other.right_value == self.right_value
end

#inspectString

Returns a String containing a human-readable representation of this object.

Returns:

  • (String)

    Returns a String containing a human-readable representation of this object.



142
143
144
# File 'lib/rumonade/either.rb', line 142

def inspect
  "Right(#{right_value.inspect})"
end

#to_sString

Returns a String representation of this object.

Returns:

  • (String)

    Returns a String representation of this object.



137
138
139
# File 'lib/rumonade/either.rb', line 137

def to_s
  "Right(#{right_value})"
end