Class: RubyCoded::Chat::InputHandler

Inherits:
Object
  • Object
show all
Includes:
ModalInputs, NormalModeInput
Defined in:
lib/ruby_coded/chat/input_handler.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: ModalInputs, NormalModeInput

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ InputHandler

Returns a new instance of InputHandler.



15
16
17
# File 'lib/ruby_coded/chat/input_handler.rb', line 15

def initialize(state)
  @state = state
end

Instance Method Details

#process(event) ⇒ Object



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

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