Class: RFunk::Some

Inherits:
Option show all
Defined in:
lib/rfunk/maybe/some.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Option

#each

Constructor Details

#initialize(value) ⇒ Some



5
6
7
# File 'lib/rfunk/maybe/some.rb', line 5

def initialize(value)
  @value = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object



13
14
15
# File 'lib/rfunk/maybe/some.rb', line 13

def method_missing(method, *arguments, &block)
  Option(value.send(method, *arguments, &block))
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/rfunk/maybe/some.rb', line 3

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
# File 'lib/rfunk/maybe/some.rb', line 23

def <=>(other)
  value <=> other.value
end

#==(other) ⇒ Object



17
18
19
20
21
# File 'lib/rfunk/maybe/some.rb', line 17

def ==(other)
  return false unless self.class == other.class

  value == other.value
end

#or(_) ⇒ Object



9
10
11
# File 'lib/rfunk/maybe/some.rb', line 9

def or(_)
  self
end