Module: Vedeu::Input::Store
Overview
Stores each keypress or command to be retrieved later.
Class Method Summary collapse
-
.add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a command (a collection of characters/keypresses from an Editor::Document) to the store.
-
.add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a keypress to the store.
-
.all ⇒ Hash<Symbol => Array<Symbol|String>>
Access all commands and keypresses stored.
-
.all_commands ⇒ Array<Symbol|String>
Access all commands stored.
-
.all_keypresses ⇒ Array<Symbol|String>
Access all keypresses stored.
- .in_memory ⇒ Hash<Symbol => Array<Symbol|String>> private
-
.last_command ⇒ NilClass|Symbol|String
Access the last command stored.
-
.last_keypress ⇒ NilClass|Symbol|String
Access the last keypress stored.
-
.reset ⇒ Hash<Symbol => Array<Symbol|String>>
Remove all stored entries.
- .storage ⇒ Hash<Symbol => Array<Symbol|String>> private
Instance Method Summary collapse
-
#add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a command (a collection of characters/keypresses from an Editor::Document) to the store.
-
#add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a keypress to the store.
-
#all ⇒ Hash<Symbol => Array<Symbol|String>>
Access all commands and keypresses stored.
-
#all_commands ⇒ Array<Symbol|String>
Access all commands stored.
-
#all_keypresses ⇒ Array<Symbol|String>
Access all keypresses stored.
- #in_memory ⇒ Hash<Symbol => Array<Symbol|String>> private
-
#last_command ⇒ NilClass|Symbol|String
Access the last command stored.
-
#last_keypress ⇒ NilClass|Symbol|String
Access the last keypress stored.
-
#reset ⇒ Hash<Symbol => Array<Symbol|String>>
Remove all stored entries.
- #storage ⇒ Hash<Symbol => Array<Symbol|String>> private
Class Method Details
.add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a command (a collection of characters/keypresses from an Editor::Document) to the store. Used by Vedeu internally to store commands entered.
20 21 22 |
# File 'lib/vedeu/input/store.rb', line 20 def add_command(command) all_commands << command end |
.add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a keypress to the store. Used by Vedeu internally to store a keypress entered.
32 33 34 |
# File 'lib/vedeu/input/store.rb', line 32 def add_keypress(keypress) all_keypresses << keypress end |
.all ⇒ Hash<Symbol => Array<Symbol|String>>
Access all commands and keypresses stored.
39 40 41 |
# File 'lib/vedeu/input/store.rb', line 39 def all storage end |
.all_commands ⇒ Array<Symbol|String>
Access all commands stored.
49 50 51 |
# File 'lib/vedeu/input/store.rb', line 49 def all_commands storage[:commands] end |
.all_keypresses ⇒ Array<Symbol|String>
Access all keypresses stored.
59 60 61 |
# File 'lib/vedeu/input/store.rb', line 59 def all_keypresses storage[:keypresses] end |
.in_memory ⇒ Hash<Symbol => Array<Symbol|String>> (private)
103 104 105 106 107 108 |
# File 'lib/vedeu/input/store.rb', line 103 def in_memory { commands: [], keypresses: [], } end |
.last_command ⇒ NilClass|Symbol|String
Access the last command stored. If no commands have been entered since the client application started, then this will return nil.
71 72 73 |
# File 'lib/vedeu/input/store.rb', line 71 def last_command all_commands[-1] end |
.last_keypress ⇒ NilClass|Symbol|String
Access the last keypress stored. If no keys have been pressed since the client application started, then this will return nil.
83 84 85 |
# File 'lib/vedeu/input/store.rb', line 83 def last_keypress all_keypresses[-1] end |
.reset ⇒ Hash<Symbol => Array<Symbol|String>>
Remove all stored entries. Any commands or keypresses entered before calling this method will be removed.
91 92 93 |
# File 'lib/vedeu/input/store.rb', line 91 def reset @storage = in_memory end |
.storage ⇒ Hash<Symbol => Array<Symbol|String>> (private)
98 99 100 |
# File 'lib/vedeu/input/store.rb', line 98 def storage @storage ||= in_memory end |
Instance Method Details
#add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a command (a collection of characters/keypresses from an Editor::Document) to the store. Used by Vedeu internally to store commands entered.
20 21 22 |
# File 'lib/vedeu/input/store.rb', line 20 def add_command(command) all_commands << command end |
#add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>
Add a keypress to the store. Used by Vedeu internally to store a keypress entered.
32 33 34 |
# File 'lib/vedeu/input/store.rb', line 32 def add_keypress(keypress) all_keypresses << keypress end |
#all ⇒ Hash<Symbol => Array<Symbol|String>>
Access all commands and keypresses stored.
39 40 41 |
# File 'lib/vedeu/input/store.rb', line 39 def all storage end |
#all_commands ⇒ Array<Symbol|String>
Access all commands stored.
49 50 51 |
# File 'lib/vedeu/input/store.rb', line 49 def all_commands storage[:commands] end |
#all_keypresses ⇒ Array<Symbol|String>
Access all keypresses stored.
59 60 61 |
# File 'lib/vedeu/input/store.rb', line 59 def all_keypresses storage[:keypresses] end |
#in_memory ⇒ Hash<Symbol => Array<Symbol|String>> (private)
103 104 105 106 107 108 |
# File 'lib/vedeu/input/store.rb', line 103 def in_memory { commands: [], keypresses: [], } end |
#last_command ⇒ NilClass|Symbol|String
Access the last command stored. If no commands have been entered since the client application started, then this will return nil.
71 72 73 |
# File 'lib/vedeu/input/store.rb', line 71 def last_command all_commands[-1] end |
#last_keypress ⇒ NilClass|Symbol|String
Access the last keypress stored. If no keys have been pressed since the client application started, then this will return nil.
83 84 85 |
# File 'lib/vedeu/input/store.rb', line 83 def last_keypress all_keypresses[-1] end |
#reset ⇒ Hash<Symbol => Array<Symbol|String>>
Remove all stored entries. Any commands or keypresses entered before calling this method will be removed.
91 92 93 |
# File 'lib/vedeu/input/store.rb', line 91 def reset @storage = in_memory end |
#storage ⇒ Hash<Symbol => Array<Symbol|String>> (private)
98 99 100 |
# File 'lib/vedeu/input/store.rb', line 98 def storage @storage ||= in_memory end |