Class: Maybe

Inherits:
Never show all
Defined in:
lib/rmaybe.rb

Instance Attribute Summary

Attributes inherited from Never

#value

Instance Method Summary collapse

Methods inherited from Never

#maybe, #maybe?

Constructor Details

#initialize(value) ⇒ Maybe

Returns a new instance of Maybe.



28
29
30
# File 'lib/rmaybe.rb', line 28

def initialize(value)
  @value = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



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

def method_missing(*args, &block)
  @value ? Maybe.new(@value.__send__(*args, &block)) : Never.new
end

Instance Method Details

#endObject



36
37
38
# File 'lib/rmaybe.rb', line 36

def end
  @value
end