Class: Mockingbird::Commands::Command

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

Direct Known Subclasses

Close, Disconnect, Pipe, Quit, Send, Wait

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Command

Returns a new instance of Command.



7
8
9
# File 'lib/mockingbird/commands.rb', line 7

def initialize(&block)
  self.callback = block      
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



5
6
7
# File 'lib/mockingbird/commands.rb', line 5

def callback
  @callback
end

#next_commandObject

Returns the value of attribute next_command.



5
6
7
# File 'lib/mockingbird/commands.rb', line 5

def next_command
  @next_command
end

Instance Method Details

#advance(conn) ⇒ Object



16
17
18
# File 'lib/mockingbird/commands.rb', line 16

def advance(conn)
  next_command.run(conn) if next_command
end

#run(conn) ⇒ Object



11
12
13
14
# File 'lib/mockingbird/commands.rb', line 11

def run(conn)
  callback.call(conn) if callback
  advance(conn)
end