Class: Xudoku::Cli::KeyEvent
- Inherits:
-
Object
- Object
- Xudoku::Cli::KeyEvent
show all
- Defined in:
- lib/xudoku/cli/key_event.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(original_event) ⇒ KeyEvent
Returns a new instance of KeyEvent.
7
8
9
|
# File 'lib/xudoku/cli/key_event.rb', line 7
def initialize(original_event)
@original_event = original_event
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs) ⇒ Object
64
65
66
67
|
# File 'lib/xudoku/cli/key_event.rb', line 64
def method_missing(method_name, *args, **kwargs)
@original_event.send(method_name, *args, **kwargs)
end
|
Instance Method Details
#backspace? ⇒ Boolean
Also known as:
delete?
31
32
33
|
# File 'lib/xudoku/cli/key_event.rb', line 31
def backspace?
key.name == :backspace
end
|
#digit ⇒ Object
40
41
42
|
# File 'lib/xudoku/cli/key_event.rb', line 40
def digit
value.to_i
end
|
#digit? ⇒ Boolean
36
37
38
|
# File 'lib/xudoku/cli/key_event.rb', line 36
def digit?
value.to_s.match?(/\d/)
end
|
#down? ⇒ Boolean
15
16
17
|
# File 'lib/xudoku/cli/key_event.rb', line 15
def down?
key.name == :down || %w[j s].include?(value)
end
|
#left? ⇒ Boolean
19
20
21
|
# File 'lib/xudoku/cli/key_event.rb', line 19
def left?
key.name == :left || %w[h a].include?(value)
end
|
48
49
50
|
# File 'lib/xudoku/cli/key_event.rb', line 48
def
value.downcase == "b"
end
|
#quit? ⇒ Boolean
44
45
46
|
# File 'lib/xudoku/cli/key_event.rb', line 44
def quit?
value.downcase == "q"
end
|
#respond_to_missing?(method_name) ⇒ Boolean
60
61
62
|
# File 'lib/xudoku/cli/key_event.rb', line 60
def respond_to_missing?(method_name)
@original_event.respond_to?(method_name)
end
|
#restart? ⇒ Boolean
52
53
54
|
# File 'lib/xudoku/cli/key_event.rb', line 52
def restart?
value.downcase == "r"
end
|
#return? ⇒ Boolean
27
28
29
|
# File 'lib/xudoku/cli/key_event.rb', line 27
def return?
key.name == :return
end
|
#right? ⇒ Boolean
23
24
25
|
# File 'lib/xudoku/cli/key_event.rb', line 23
def right?
key.name == :right || %w[d l].include?(value)
end
|
#undo? ⇒ Boolean
56
57
58
|
# File 'lib/xudoku/cli/key_event.rb', line 56
def undo?
value.downcase == "u"
end
|
#up? ⇒ Boolean
11
12
13
|
# File 'lib/xudoku/cli/key_event.rb', line 11
def up?
key.name == :up || %w[w k].include?(value)
end
|