Class: AimsProject::CommandHistory
- Inherits:
-
Object
- Object
- AimsProject::CommandHistory
- Defined in:
- lib/aims_project/geometry_console.rb
Instance Method Summary collapse
-
#initialize ⇒ CommandHistory
constructor
A new instance of CommandHistory.
- #prev ⇒ Object
- #save(cmd) ⇒ Object
- #succ ⇒ Object
Constructor Details
#initialize ⇒ CommandHistory
Returns a new instance of CommandHistory.
6 7 8 9 |
# File 'lib/aims_project/geometry_console.rb', line 6 def initialize @history= [] @counter = 0 end |
Instance Method Details
#prev ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/aims_project/geometry_console.rb', line 16 def prev @counter = @history.size unless @counter if @counter > 0 @counter = @counter - 1 end @history[@counter] end |
#save(cmd) ⇒ Object
11 12 13 14 |
# File 'lib/aims_project/geometry_console.rb', line 11 def save(cmd) @history.push(cmd) @counter = @history.size end |
#succ ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/aims_project/geometry_console.rb', line 24 def succ @counter = @history.size unless @counter if @counter < @history.size-1 @counter = @counter + 1 end @history[@counter] end |