Class: Meshchat::Ui::Command::Whisper
- Inherits:
-
Base
- Object
- Base
- Meshchat::Ui::Command::Whisper
show all
- Defined in:
- lib/meshchat/ui/command/whisper.rb
Constant Summary
Constants inherited
from Base
Base::ADD, Base::ALL_CHAT_LOCK, Base::BIND, Base::CHAT, Base::CONFIG, Base::DISPLAY, Base::EMOTE, Base::EXIT, Base::EXPORT, Base::HELP, Base::IDENTITY, Base::IMPORT, Base::IRB, Base::OFFLINE, Base::ONLINE, Base::PING, Base::PING_ALL, Base::QUIT, Base::REMOVE, Base::RM, Base::ROLL, Base::SEND_DISCONNECT, Base::SERVER, Base::SERVERS, Base::SET, Base::SHARE, Base::WHISPER_LOCK, Base::WHO
Instance Attribute Summary collapse
Attributes inherited from Base
#_input, #_input_factory, #_message_dispatcher, #_message_factory
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Attribute Details
#_target_node ⇒ Object
Returns the value of attribute _target_node.
6
7
8
|
# File 'lib/meshchat/ui/command/whisper.rb', line 6
def _target_node
@_target_node
end
|
Class Method Details
.description ⇒ Object
8
9
10
|
# File 'lib/meshchat/ui/command/whisper.rb', line 8
def self.description
'sends a private message to a spepcific person'
end
|
Instance Method Details
#find_node_and_whisper(target) ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/meshchat/ui/command/whisper.rb', line 42
def find_node_and_whisper(target)
NodeFinder.find_by_target(target) do |node|
if node
send_message_to_node(node)
else
Display.alert "node for #{target} not found or is not online"
end
end
end
|
#handle ⇒ Object
23
24
25
26
|
# File 'lib/meshchat/ui/command/whisper.rb', line 23
def handle
return send_message_to_node(_target_node) if _target_node
find_node_and_whisper(target)
end
|
#message ⇒ Object
18
19
20
21
|
# File 'lib/meshchat/ui/command/whisper.rb', line 18
def message
return _input if _target_node
command_args[1..command_args.length].try(:join, ' ')
end
|
#send_message_to_node(node) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/meshchat/ui/command/whisper.rb', line 28
def send_message_to_node(node)
m = _message_factory.create(
Network::Message::WHISPER,
data: {
message: message,
to: target
}
)
Display.whisper m.display
_message_dispatcher.send_message(node: node, message: m)
end
|
#target ⇒ Object
12
13
14
15
16
|
# File 'lib/meshchat/ui/command/whisper.rb', line 12
def target
return _target_node.alias_name if _target_node
command
end
|