Class: Pantry::Commands::Echo

Inherits:
Pantry::Command show all
Defined in:
lib/pantry/commands/echo.rb

Overview

Simple Echo command, returns the body of the Message given.

Direct Known Subclasses

ServerEchoCommand

Instance Method Summary collapse

Methods inherited from Pantry::Command

command, #finished, #finished?, message_type, #prepare_message, #receive_response, #receive_server_response, #send_request, #send_request!, #server_or_client, #server_or_client=, #wait_for_finish

Constructor Details

#initialize(string_to_echo = "") ⇒ Echo

Returns a new instance of Echo.



11
12
13
# File 'lib/pantry/commands/echo.rb', line 11

def initialize(string_to_echo = "")
  @string_to_echo = string_to_echo
end

Instance Method Details

#perform(message) ⇒ Object



21
22
23
# File 'lib/pantry/commands/echo.rb', line 21

def perform(message)
  message.body[0]
end

#receive_client_response(response) ⇒ Object



25
26
27
# File 'lib/pantry/commands/echo.rb', line 25

def receive_client_response(response)
  Pantry.ui.say("#{response.from} echo's #{response.body[0].inspect}")
end

#to_messageObject



15
16
17
18
19
# File 'lib/pantry/commands/echo.rb', line 15

def to_message
  message = super
  message << @string_to_echo
  message
end