Module: Ray::Matchers

Included in:
Helper
Defined in:
lib/ray/dsl/matcher.rb

Overview

This is the module including all of your matchers as private methods, allowing you to use them when you call on.

Class Method Summary collapse

Class Method Details

.key(name) ⇒ Ray::Key

Returns A key object representing the key of that name.

Returns:

  • (Ray::Key)

    A key object representing the key of that name



24
25
26
# File 'lib/ray/dsl/matcher.rb', line 24

def key(name)
  Key.new(name)
end

.key_mod(name) ⇒ Ray::KeyMod

Returns A key_mod object representing the mod combination of that name.

Returns:

  • (Ray::KeyMod)

    A key_mod object representing the mod combination of that name



30
31
32
# File 'lib/ray/dsl/matcher.rb', line 30

def key_mod(name)
  KeyMod.new(name)
end

.where(&block) ⇒ DSL::Matcher

Returns An anonymous matcher, using your block to know if the argument matches.

Examples:

on :foo, where { |i| i > 10 } do |i|
  puts "#{i} is greater than 10!"
end

Returns:

  • (DSL::Matcher)

    An anonymous matcher, using your block to know if the argument matches.



19
20
21
# File 'lib/ray/dsl/matcher.rb', line 19

def where(&block)
  DSL::Matcher.new { |o| block.call(o) }
end