Class: Data::Option::None

Inherits:
Object
  • Object
show all
Includes:
Comparable, Singleton
Defined in:
lib/data/option/none.rb

Defined Under Namespace

Classes: UnwrapError

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



16
# File 'lib/data/option/none.rb', line 16

def <=>(other) = other.is_a?(Some) ? -1 : 0

#and(_other) ⇒ Object



28
# File 'lib/data/option/none.rb', line 28

def and(_other) = self

#and_thenObject



29
# File 'lib/data/option/none.rb', line 29

def and_then = self

#eachObject Also known as: map, filter, flat_map, flatten



34
# File 'lib/data/option/none.rb', line 34

def each = self

#expect(message) ⇒ Object

Raises:



26
# File 'lib/data/option/none.rb', line 26

def expect(message) = raise UnwrapError, message

#inspectObject Also known as: to_s



49
# File 'lib/data/option/none.rb', line 49

def inspect = 'None'

#map_or_else(default) ⇒ Object



41
# File 'lib/data/option/none.rb', line 41

def map_or_else(default) = default.call

#none?Boolean Also known as: none_or?

Returns:

  • (Boolean)


44
# File 'lib/data/option/none.rb', line 44

def none? = true

#or(other) ⇒ Object Also known as: xor



30
# File 'lib/data/option/none.rb', line 30

def or(other) = other.is_a?(Some) ? other : self

#pretty_print(pp) ⇒ Object



52
# File 'lib/data/option/none.rb', line 52

def pretty_print(pp) = pp.text(inspect)

#some?Boolean Also known as: some_and?

Returns:

  • (Boolean)


43
# File 'lib/data/option/none.rb', line 43

def some? = false

#unwrapObject

Raises:



22
# File 'lib/data/option/none.rb', line 22

def unwrap = raise UnwrapError

#unwrap_or(default) ⇒ Object Also known as: map_or



25
# File 'lib/data/option/none.rb', line 25

def unwrap_or(default) = default

#unwrap_or_elseObject Also known as: or_else



23
# File 'lib/data/option/none.rb', line 23

def unwrap_or_else = yield