class Left
Public Class Methods
new(value)
click to toggle source
# File lib/totally_lazy/either.rb, line 60 def initialize(value) @value = value end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/totally_lazy/either.rb, line 94 def <=>(other) @value <=> other.left_value end
flat_map(fn=nil, &block)
click to toggle source
# File lib/totally_lazy/either.rb, line 85 def flat_map(fn=nil, &block) # a function which returns an either assert_funcs(fn, block_given?) self end
fold(seed, fn_left, fn_right)
click to toggle source
# File lib/totally_lazy/either.rb, line 90 def fold(seed, fn_left, fn_right) fn_left.(seed, @value) end
is_left?()
click to toggle source
# File lib/totally_lazy/either.rb, line 64 def is_left? true end
is_right?()
click to toggle source
# File lib/totally_lazy/either.rb, line 68 def is_right? false end
left_value()
click to toggle source
# File lib/totally_lazy/either.rb, line 72 def left_value @value end
map_left(fn=nil, &block)
click to toggle source
# File lib/totally_lazy/either.rb, line 80 def map_left(fn=nil, &block) assert_funcs(fn, block_given?) left(block_given? ? block.call(@value) : fn.(@value)) end
right_value()
click to toggle source
# File lib/totally_lazy/either.rb, line 76 def right_value raise NoSuchElementException.new end
to_s()
click to toggle source
# File lib/totally_lazy/either.rb, line 98 def to_s "left(#{@value})" end