Class: Roflbot::Base::Expectation
- Inherits:
-
Object
- Object
- Roflbot::Base::Expectation
- Defined in:
- lib/roflbot/base.rb
Instance Method Summary collapse
-
#initialize(regexp) ⇒ Expectation
constructor
A new instance of Expectation.
- #matches?(message) ⇒ Boolean
- #responds(message = nil, &block) ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(regexp) ⇒ Expectation
Returns a new instance of Expectation.
4 5 6 |
# File 'lib/roflbot/base.rb', line 4 def initialize(regexp) @regexp = regexp end |
Instance Method Details
#matches?(message) ⇒ Boolean
8 9 10 |
# File 'lib/roflbot/base.rb', line 8 def matches?() @regexp =~ end |
#responds(message = nil, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/roflbot/base.rb', line 12 def responds( = nil, &block) if block_given? @response = block else @response = end end |
#response ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/roflbot/base.rb', line 20 def response case @response when String @response when Proc @response.call end end |