Class: Meshchat::Ui::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/meshchat/ui/command/base.rb

Constant Summary collapse

SET =

Commands

'set'
CONFIG =
'config'
DISPLAY =
'display'
EXIT =
'exit'
QUIT =
'quit'
CHAT =
'chat'
ADD =
'add'
REMOVE =
'remove'
RM =
'rm'
SERVERS =
'servers'
SERVER =
'server'
WHO =
'who'
PING =
'ping'
PING_ALL =
'pingall'
IDENTITY =
'identity'
IRB =
'c'
SHARE =
'share'
IMPORT =
'import'
EXPORT =
'export'
ONLINE =
'online'
OFFLINE =
'offline'
HELP =
'help'
BIND =
'bind'
SEND_DISCONNECT =
'senddisconnect'
EMOTE =
'me'
ROLL =
'roll'
WHISPER_LOCK =
'wl'
ALL_CHAT_LOCK =
'all'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, message_dispatcher, message_factory, input_factory) ⇒ Base

Returns a new instance of Base.



39
40
41
42
43
44
# File 'lib/meshchat/ui/command/base.rb', line 39

def initialize(input, message_dispatcher, message_factory, input_factory)
  @_input              = input&.chomp
  @_message_dispatcher = message_dispatcher
  @_message_factory    = message_factory
  @_input_factory      = input_factory
end

Instance Attribute Details

#_inputObject (readonly)

Returns the value of attribute _input.



36
37
38
# File 'lib/meshchat/ui/command/base.rb', line 36

def _input
  @_input
end

#_input_factoryObject (readonly)

Returns the value of attribute _input_factory.



37
38
39
# File 'lib/meshchat/ui/command/base.rb', line 37

def _input_factory
  @_input_factory
end

#_message_dispatcherObject (readonly)

Returns the value of attribute _message_dispatcher.



36
37
38
# File 'lib/meshchat/ui/command/base.rb', line 36

def _message_dispatcher
  @_message_dispatcher
end

#_message_factoryObject (readonly)

Returns the value of attribute _message_factory.



37
38
39
# File 'lib/meshchat/ui/command/base.rb', line 37

def _message_factory
  @_message_factory
end

Instance Method Details

#handleObject



46
47
48
49
50
51
52
53
54
# File 'lib/meshchat/ui/command/base.rb', line 46

def handle
  klass = COMMAND_MAP[command]
  Display.debug("INPUT: #{klass&.name} from #{command} derived from #{_input}")
  if klass
    _input_factory.create(for_input: _input, with_class: klass).handle
  else
    Display.alert "#{command} not implemented..."
  end
end