Class: RubyCoded::Chat::InputHandler

Inherits:
Object
  • Object
show all
Includes:
LoginInputs, ModalInputs, NormalModeInput
Defined in:
lib/ruby_coded/chat/input_handler.rb,
lib/ruby_coded/chat/input_handler/login_inputs.rb,
lib/ruby_coded/chat/input_handler/modal_inputs.rb,
lib/ruby_coded/chat/input_handler/normal_mode_input.rb

Overview

This class is used to handle the input events for the chat

Defined Under Namespace

Modules: LoginInputs, ModalInputs, NormalModeInput

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ InputHandler

Returns a new instance of InputHandler.



17
18
19
# File 'lib/ruby_coded/chat/input_handler.rb', line 17

def initialize(state)
  @state = state
end

Instance Method Details

#process(event) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/ruby_coded/chat/input_handler.rb', line 21

def process(event)
  return handle_paste(event) if event.is_a?(RatatuiRuby::Event::Paste)
  return handle_mouse(event) if event.is_a?(RatatuiRuby::Event::Mouse)
  return nil unless event.key?

  dispatch_key_event(event)
end