Class: MeshChat::Command::Whisper

Inherits:
Base show all
Defined in:
lib/meshchat/command/whisper.rb

Constant Summary

Constants inherited from Base

Base::ADD, Base::CHAT, Base::CONFIG, Base::CONNECT, Base::DISPLAY, Base::EXIT, Base::EXPORT, Base::IDENTITY, Base::IMPORT, Base::INIT, Base::IRB, Base::LISTEN, Base::PING, Base::PING_ALL, Base::QUIT, Base::REMOVE, Base::RM, Base::SERVER, Base::SERVERS, Base::SET, Base::SHARE, Base::STOP_LISTENING, Base::WHO

Constants inherited from MeshChat::CLI::Input

MeshChat::CLI::Input::COMMAND, MeshChat::CLI::Input::WHISPER

Instance Attribute Summary

Attributes inherited from Base

#_input

Attributes inherited from MeshChat::CLI::Input

#_input

Instance Method Summary collapse

Methods inherited from MeshChat::CLI::Input

create, #initialize, is_command, is_whisper?

Constructor Details

This class inherits a constructor from MeshChat::CLI::Input

Instance Method Details

#handleObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/meshchat/command/whisper.rb', line 13

def handle
  node = Node.find_by_alias_name(target)

  if node
    m = Message::Whisper.new(
      message: message,
      to: target
    )

    Display.whisper m.display

    Net::Client.send(
      node: node,
      message: m
    )
  else
    Display.alert "node for #{target} not found or is not online"
  end
end

#messageObject



9
10
11
# File 'lib/meshchat/command/whisper.rb', line 9

def message
  command_args[1..command_args.length].try(:join, ' ')
end

#targetObject



4
5
6
7
# File 'lib/meshchat/command/whisper.rb', line 4

def target
  # get first arg
  command
end