Class: Vedeu::Input::Store
- Inherits:
-
Object
- Object
- Vedeu::Input::Store
- Defined in:
- lib/vedeu/input/store.rb
Overview
Stores each keypress or command to be retrieved later.
Instance Method Summary collapse
- #add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
- #add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
- #all ⇒ Hash<Symbol => Array<Symbol|String>>
- #all_commands ⇒ Array<Symbol|String>
- #all_keypresses ⇒ Array<Symbol|String>
- #in_memory ⇒ Hash<Symbol => Array<Symbol|String>> private
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #last_command ⇒ NilClass|Symbol|String
- #last_keypress ⇒ NilClass|Symbol|String
- #reset ⇒ Hash<Symbol => Array<Symbol|String>>
- #storage ⇒ Hash<Symbol => Array<Symbol|String>> private
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
9 10 |
# File 'lib/vedeu/input/store.rb', line 9 def initialize end |
Instance Method Details
#add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
13 14 15 |
# File 'lib/vedeu/input/store.rb', line 13 def add_command(command) all_commands << command end |
#add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
18 19 20 |
# File 'lib/vedeu/input/store.rb', line 18 def add_keypress(keypress) all_keypresses << keypress end |
#all ⇒ Hash<Symbol => Array<Symbol|String>>
23 24 25 |
# File 'lib/vedeu/input/store.rb', line 23 def all storage end |
#all_commands ⇒ Array<Symbol|String>
28 29 30 |
# File 'lib/vedeu/input/store.rb', line 28 def all_commands storage[:commands] end |
#all_keypresses ⇒ Array<Symbol|String>
33 34 35 |
# File 'lib/vedeu/input/store.rb', line 33 def all_keypresses storage[:keypresses] end |
#in_memory ⇒ Hash<Symbol => Array<Symbol|String>> (private)
60 61 62 63 64 65 |
# File 'lib/vedeu/input/store.rb', line 60 def in_memory { commands: [], keypresses: [], } end |
#last_command ⇒ NilClass|Symbol|String
38 39 40 |
# File 'lib/vedeu/input/store.rb', line 38 def last_command all_commands[-1] end |
#last_keypress ⇒ NilClass|Symbol|String
43 44 45 |
# File 'lib/vedeu/input/store.rb', line 43 def last_keypress all_keypresses[-1] end |
#reset ⇒ Hash<Symbol => Array<Symbol|String>>
48 49 50 |
# File 'lib/vedeu/input/store.rb', line 48 def reset @storage = in_memory end |
#storage ⇒ Hash<Symbol => Array<Symbol|String>> (private)
55 56 57 |
# File 'lib/vedeu/input/store.rb', line 55 def storage @storage ||= in_memory end |