Class: PatternMatching::Guard

Inherits:
Object
  • Object
show all
Defined in:
lib/pattern_matching.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(func, clazz, matcher) ⇒ Guard

:nodoc:



13
14
15
16
17
# File 'lib/pattern_matching.rb', line 13

def initialize(func, clazz, matcher) # :nodoc:

  @func = func
  @clazz = clazz
  @matcher = matcher
end

Instance Method Details

#when(&block) ⇒ Object

:nodoc:



18
19
20
21
22
23
24
# File 'lib/pattern_matching.rb', line 18

def when(&block) # :nodoc:

  unless block_given?
    raise ArgumentError.new("block missing for `when` guard on function `#{@func}` of class #{@clazz}")
  end
  @matcher[@matcher.length-1] = block
  return nil
end