Class: TypedCache::Left

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Left

: (E) -> void



47
48
49
# File 'lib/typed_cache/either.rb', line 47

def initialize(error)
  @error = error
end

Instance Attribute Details

#errorObject (readonly) Also known as: value

@rbs! include _Either[E, bot]



42
43
44
# File 'lib/typed_cache/either.rb', line 42

def error
  @error
end

Instance Method Details

#==(other) ⇒ Object



91
92
93
# File 'lib/typed_cache/either.rb', line 91

def ==(other)
  other.is_a?(Left) && other.error == error
end

#bindObject

: [E2, R2] () { ® -> either[E2, R2] } -> either[E | E2, R2]



73
# File 'lib/typed_cache/either.rb', line 73

def bind(&) = self

#deconstruct_keys(keys) ⇒ Object

: (Array) -> ({ error: E })



86
87
88
# File 'lib/typed_cache/either.rb', line 86

def deconstruct_keys(keys)
  { error: }
end

#fold(left_fn, right_fn) ⇒ Object

: [T, E, R] (^(E) -> T, ^® -> T) -> T



81
82
83
# File 'lib/typed_cache/either.rb', line 81

def fold(left_fn, right_fn)
  left_fn.call(error)
end

#hashObject



96
# File 'lib/typed_cache/either.rb', line 96

def hash = [Left, error].hash

#inspectObject



102
# File 'lib/typed_cache/either.rb', line 102

def inspect = "Left(#{error.inspect})"

#left?Boolean

: -> true

Returns:

  • (Boolean)


53
# File 'lib/typed_cache/either.rb', line 53

def left? = true

#mapObject

: [T] () { ® -> T } -> either[E, T]



69
# File 'lib/typed_cache/either.rb', line 69

def map(&) = self

#map_leftObject

: [F] () { (E) -> F } -> either[F, R]



77
# File 'lib/typed_cache/either.rb', line 77

def map_left(&) = Left.new(yield(error))

#right?Boolean

: -> false

Returns:

  • (Boolean)


57
# File 'lib/typed_cache/either.rb', line 57

def right? = false

#right_or_else {|error| ... } ⇒ Object

: (^(E) -> void) -> bot

Yields:



61
# File 'lib/typed_cache/either.rb', line 61

def right_or_else(&) = yield(error)

#right_or_raise!Object

: -> bot



65
# File 'lib/typed_cache/either.rb', line 65

def right_or_raise! = raise(error)

#to_sObject



99
# File 'lib/typed_cache/either.rb', line 99

def to_s = "Left(#{error})"