Class: SiriSays::Plugins

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

Class Method Summary collapse

Class Method Details

.add(regex, block) ⇒ Object



15
16
17
18
19
20
# File 'lib/siri_says.rb', line 15

def add( regex, block )
  (@plugins ||= []) << {
    regex: regex,
    block: block
  }
end

.handle(message) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/siri_says.rb', line 22

def handle( message )
  (@plugins || []).each do |plugin|
    if message =~ plugin[:regex]
      plugin[:block].call( message )
    end
  end
end