Module: Vedeu::Input::Store

Extended by:
Store, Repositories::Storage
Included in:
Store
Defined in:
lib/vedeu/input/store.rb

Overview

Stores each keypress or command to be retrieved later.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>

Parameters:

  • command (Symbol|String)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


17
18
19
# File 'lib/vedeu/input/store.rb', line 17

def add_command(command)
  all_commands << command
end

.add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>

Parameters:

  • keypress (Symbol|String)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


24
25
26
# File 'lib/vedeu/input/store.rb', line 24

def add_keypress(keypress)
  all_keypresses << keypress
end

.all_commandsArray<Symbol|String>

Returns:

  • (Array<Symbol|String>)


30
31
32
# File 'lib/vedeu/input/store.rb', line 30

def all_commands
  storage[:commands]
end

.all_keypressesArray<Symbol|String>

Returns:

  • (Array<Symbol|String>)


36
37
38
# File 'lib/vedeu/input/store.rb', line 36

def all_keypresses
  storage[:keypresses]
end

.in_memoryHash<Symbol => Array<Symbol|String>> (private)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


55
56
57
58
59
60
# File 'lib/vedeu/input/store.rb', line 55

def in_memory
  {
    commands:   [],
    keypresses: [],
  }
end

.last_commandNilClass|Symbol|String

Returns:

  • (NilClass|Symbol|String)


42
43
44
# File 'lib/vedeu/input/store.rb', line 42

def last_command
  all_commands[-1]
end

.last_keypressNilClass|Symbol|String

Returns:

  • (NilClass|Symbol|String)


48
49
50
# File 'lib/vedeu/input/store.rb', line 48

def last_keypress
  all_keypresses[-1]
end

.reset!void Also known as: reset Originally defined in module Repositories::Storage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Remove all currently stored data for this repository.

.storagevoid Also known as: all Originally defined in module Repositories::Storage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Return whole repository; provides raw access to the storage for this repository.

Instance Method Details

#add_command(command) ⇒ Hash<Symbol => Array<Symbol|String>>

Parameters:

  • command (Symbol|String)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


17
18
19
# File 'lib/vedeu/input/store.rb', line 17

def add_command(command)
  all_commands << command
end

#add_keypress(keypress) ⇒ Hash<Symbol => Array<Symbol|String>>

Parameters:

  • keypress (Symbol|String)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


24
25
26
# File 'lib/vedeu/input/store.rb', line 24

def add_keypress(keypress)
  all_keypresses << keypress
end

#all_commandsArray<Symbol|String>

Returns:

  • (Array<Symbol|String>)


30
31
32
# File 'lib/vedeu/input/store.rb', line 30

def all_commands
  storage[:commands]
end

#all_keypressesArray<Symbol|String>

Returns:

  • (Array<Symbol|String>)


36
37
38
# File 'lib/vedeu/input/store.rb', line 36

def all_keypresses
  storage[:keypresses]
end

#in_memoryHash<Symbol => Array<Symbol|String>> (private)

Returns:

  • (Hash<Symbol => Array<Symbol|String>>)


55
56
57
58
59
60
# File 'lib/vedeu/input/store.rb', line 55

def in_memory
  {
    commands:   [],
    keypresses: [],
  }
end

#last_commandNilClass|Symbol|String

Returns:

  • (NilClass|Symbol|String)


42
43
44
# File 'lib/vedeu/input/store.rb', line 42

def last_command
  all_commands[-1]
end

#last_keypressNilClass|Symbol|String

Returns:

  • (NilClass|Symbol|String)


48
49
50
# File 'lib/vedeu/input/store.rb', line 48

def last_keypress
  all_keypresses[-1]
end