Class: Responder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blockObject

Returns the value of attribute block.



2
3
4
# File 'lib/responder.rb', line 2

def block
  @block
end

#commandObject

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

Returns:

  • (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