Class: Maybe::Just

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/maybe.rb

Instance Method Summary collapse

Methods included from Shared

#==, #val_eq?

Constructor Details

#initialize(val) ⇒ Just

Returns a new instance of Just.



39
40
41
# File 'lib/maybe.rb', line 39

def initialize(val)
  @val = val
end

Instance Method Details

#flat_map {|val| ... } ⇒ Object

Yields:

  • (val)


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

def flat_map
  yield val
end

#is_just?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/maybe.rb', line 32

def is_just?
  true
end

#is_nothing?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/maybe.rb', line 35

def is_nothing?
  false
end

#mapObject



43
44
45
# File 'lib/maybe.rb', line 43

def map
  Maybe.new { yield val }
end