Class: FourTwoSeven::Command
- Inherits:
-
Object
- Object
- FourTwoSeven::Command
- Defined in:
- lib/427/command.rb
Constant Summary collapse
- KEYS =
[ *"A".."Z", *"a".."z", *"0".."9", " " ]
- DURATION =
0..15
- PROMPT =
"> Please PRESS '%s' on your KEYBOARD for %ss.\n"
- SEPARATOR =
"\n\n- - -\n"
Instance Attribute Summary collapse
-
#prev_command ⇒ Object
Returns the value of attribute prev_command.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(prev_command = nil) ⇒ Command
constructor
A new instance of Command.
- #key ⇒ Object
- #prompt ⇒ Object
Constructor Details
#initialize(prev_command = nil) ⇒ Command
Returns a new instance of Command.
19 20 21 |
# File 'lib/427/command.rb', line 19 def initialize(prev_command = nil) @prev_command = prev_command end |
Instance Attribute Details
#prev_command ⇒ Object
Returns the value of attribute prev_command.
17 18 19 |
# File 'lib/427/command.rb', line 17 def prev_command @prev_command end |
Instance Method Details
#duration ⇒ Object
31 32 33 34 |
# File 'lib/427/command.rb', line 31 def duration 0 #@duration ||= rand(DURATION) end |
#key ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/427/command.rb', line 23 def key @key ||= if prev_command KEYS - [prev_command.key] else KEYS end.sample end |
#prompt ⇒ Object
36 37 38 |
# File 'lib/427/command.rb', line 36 def prompt PROMPT % [key, duration] end |