Module: InputLists

Included in:
Keyboard
Defined in:
tomes/conjurations/keyboard/input_lists.rb

Overview

A module containing all the sets of input presses used by the Keyboard class and its modules.

Instance Method Summary collapse

Instance Method Details

#alphabetArray<Symbols>

A list of alphabet symbols.

Returns:

  • (Array<Symbols>)


7
8
9
10
11
12
13
14
15
16
# File 'tomes/conjurations/keyboard/input_lists.rb', line 7

def alphabet
  %i[
    a b c d e f g
    h i j k l m n o p
    q r s
    t u v
    w x
    y z
  ]
end

#button_inputsHash

Note:

Directions are included.

All controller-style buttons as a Hash with mixed values.

Returns:

  • (Hash)

    The hash keys are the reference input (such as on a Nintendo controller). The values are the accepted key or array of keys for said input.



83
84
85
86
87
88
89
90
91
92
# File 'tomes/conjurations/keyboard/input_lists.rb', line 83

def button_inputs
  {
    A: %i[c j],
    B: %i[x k],
    X: %i[z l],
    Y: %i[shift semicolon],
    START: :enter,
    SELECT: :space
  }.merge(directions)
end

#common_punctuationArray<Symbols>

A list of common_punctuation symbols.

Returns:

  • (Array<Symbols>)


20
21
22
23
24
25
26
# File 'tomes/conjurations/keyboard/input_lists.rb', line 20

def common_punctuation
  %i[
    comma period exclamation_mark question_mark colon semicolon
    less_than greater_than equal
    space enter shift tab backspace
  ]
end

#confirm_button_inputsHash

A hash of common confirm/deny buttons.

Returns:

  • (Hash)

    The hash keys are the reference input, stated as “yes” or “no”. The values are arrays of accepted keys for said input.



97
98
99
100
101
102
# File 'tomes/conjurations/keyboard/input_lists.rb', line 97

def confirm_button_inputs
  {
    yes: %i[j enter c],
    no: %i[k x]
  }
end

#direction_inputsHash<Array>

The directional arrows or WASD keys as a hash of arrays containing both options.

Returns:

  • (Hash<Array>)

    The hash keys are the directions and their values are arrays. The first element in the array is the arrow key; the second is its WASD counterpart.



70
71
72
73
74
75
76
77
# File 'tomes/conjurations/keyboard/input_lists.rb', line 70

def direction_inputs
  {
    up: %i[up_arrow w],
    down: %i[down_arrow s],
    left: %i[left_arrow a],
    right: %i[right_arrow d]
  }
end

#enclosing_punctuationArray<Symbols>

A list of enclosing_punctuation symbols.

Returns:

  • (Array<Symbols>)


39
40
41
42
43
44
# File 'tomes/conjurations/keyboard/input_lists.rb', line 39

def enclosing_punctuation
  %i[
    open_square_brace close_square_brace open_round_brace close_round_brace
    single_quotation_mark double_quotation_mark
  ]
end

#keysHash

Note:

This method has not been tested!

All other lists in this module merged into one.

Returns:

  • (Hash)


107
108
109
# File 'tomes/conjurations/keyboard/input_lists.rb', line 107

def keys
  letter_inputs.to_h + number_inputs + direction_inputs + button_inputs + confirm_button_inputs
end

#letter_inputsArray

Any key that is not a number or directional arrow.

Returns:

  • (Array)


48
49
50
51
52
53
# File 'tomes/conjurations/keyboard/input_lists.rb', line 48

def letter_inputs
  alphabet +
    common_punctuation +
    uncommon_punctuation +
    enclosing_punctuation
end

#number_inputsHash

All ten number keys as a hash.

Returns:

  • (Hash)

    The hash keys are “numbers” and their values are “numerals”.



57
58
59
60
61
62
63
64
65
# File 'tomes/conjurations/keyboard/input_lists.rb', line 57

def number_inputs
  {
    one: 1, two: 2,
    three: 3, four: 4,
    five: 5, six: 6,
    seven: 7, eight: 8,
    nine: 9, zero: 0
  }
end

#uncommon_punctuationArray<Symbols>

A list of uncommon_punctuation symbols.

Returns:

  • (Array<Symbols>)


30
31
32
33
34
35
# File 'tomes/conjurations/keyboard/input_lists.rb', line 30

def uncommon_punctuation
  %i[
    meta alt control
    forward_slash back_slash
  ]
end