Module: Kind::Result::Abstract

Included in:
Monad
Defined in:
lib/kind/result/abstract.rb

Instance Method Summary collapse

Instance Method Details

#failed?Boolean

Returns:



9
10
11
# File 'lib/kind/result/abstract.rb', line 9

def failed?
  failure?
end

#failure?Boolean

Returns:



5
6
7
# File 'lib/kind/result/abstract.rb', line 5

def failure?
  false
end

#on(&block) ⇒ Object

Raises:

  • (NotImplementedError)


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

def on(&block)
  raise NotImplementedError
end

#on_failure(types = Undefined, matcher = Undefined) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/kind/result/abstract.rb', line 29

def on_failure(types = Undefined, matcher = Undefined)
  raise NotImplementedError
end

#on_success(types = Undefined, matcher = Undefined) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/kind/result/abstract.rb', line 25

def on_success(types = Undefined, matcher = Undefined)
  raise NotImplementedError
end

#result?(types, matcher) ⇒ Boolean

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/kind/result/abstract.rb', line 33

def result?(types, matcher)
  undef_t = Undefined == (t = types)
  undef_m = Undefined == (m = matcher)

  return true if undef_t && undef_m

  if !undef_t && undef_m && !(Array === types || Symbol === types)
    m, t = types, matcher

    undef_m, undef_t = false, true
  end

  is_type = undef_t || (::Array === t ? t.empty? || t.include?(type) : t == type)
  is_type && (undef_m || m === value)
end

#succeeded?Boolean

Returns:



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

def succeeded?
  success?
end

#success?Boolean

Returns:



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

def success?
  false
end

#to_aryObject



49
50
51
# File 'lib/kind/result/abstract.rb', line 49

def to_ary
  [type, value]
end