Class: NotMonads::Result::Success

Inherits:
NotMonads::Result show all
Defined in:
lib/not_monads/result.rb

Instance Attribute Summary

Attributes inherited from NotMonads::Result

#failure, #success

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Success

Returns a new instance of Success.



8
9
10
11
# File 'lib/not_monads/result.rb', line 8

def initialize(value)
  super()
  @success = value
end

Instance Method Details

#==(other) ⇒ Object



34
35
36
# File 'lib/not_monads/result.rb', line 34

def ==(other)
  other.is_a?(self.class) && value! == other.value!
end

#===(other) ⇒ Object



38
39
40
# File 'lib/not_monads/result.rb', line 38

def ===(other)
  other.instance_of?(self.class) && value! === other.value!
end

#failure?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/not_monads/result.rb', line 13

def failure?
  false
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/not_monads/result.rb', line 17

def success?
  true
end

#to_sObject Also known as: inspect



21
22
23
# File 'lib/not_monads/result.rb', line 21

def to_s
  "Success(#{success.inspect})"
end

#value!Object



26
27
28
# File 'lib/not_monads/result.rb', line 26

def value!
  success
end

#value_or(_val = nil) ⇒ Object



30
31
32
# File 'lib/not_monads/result.rb', line 30

def value_or(_val = nil)
  success
end