Class: GitWaybackMachine::Controls
- Inherits:
-
Object
- Object
- GitWaybackMachine::Controls
- Defined in:
- lib/git_wayback_machine/controls.rb
Instance Method Summary collapse
-
#initialize ⇒ Controls
constructor
A new instance of Controls.
- #on_event(&callback) ⇒ Object
Constructor Details
#initialize ⇒ Controls
Returns a new instance of Controls.
5 6 |
# File 'lib/git_wayback_machine/controls.rb', line 5 def initialize end |
Instance Method Details
#on_event(&callback) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/git_wayback_machine/controls.rb', line 8 def on_event(&callback) while true case read_key when "\e[A" then callback.call(:up) # UP when "\e[B" then callback.call(:down) # DOWN when "\r", "\n" then callback.call(:enter) # ENTER when "\u0003", "\e" # Ctrl+C, ESC exit(0) end end end |