Class: Responder
- Inherits:
-
Object
- Object
- Responder
- Defined in:
- lib/responder.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(command, &block) ⇒ Responder
constructor
A new instance of Responder.
- #responds_to?(command) ⇒ Boolean
Constructor Details
#initialize(command, &block) ⇒ Responder
Returns a new instance of Responder.
4 5 6 7 |
# File 'lib/responder.rb', line 4 def initialize(command, &block) @command = command @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
2 3 4 |
# File 'lib/responder.rb', line 2 def block @block end |
#command ⇒ Object
Returns the value of attribute command.
2 3 4 |
# File 'lib/responder.rb', line 2 def command @command end |
Instance Method Details
#responds_to?(command) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/responder.rb', line 9 def responds_to?(command) # respond to all if our command is nil. return true if @command.nil? # otherwise parse out the command and make sure it matches # our command. @command == command.split.first end |