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.
5 6 7 8 |
# File 'lib/aims_project/geometry_console.rb', line 5 def initialize @history= [] @counter = 0 end |
Instance Method Details
#prev ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/aims_project/geometry_console.rb', line 15 def prev @counter = @history.size unless @counter if @counter > 0 @counter = @counter - 1 end @history[@counter] end |
#save(cmd) ⇒ Object
10 11 12 13 |
# File 'lib/aims_project/geometry_console.rb', line 10 def save(cmd) @history.push(cmd) @counter = @history.size end |
#succ ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/aims_project/geometry_console.rb', line 23 def succ @counter = @history.size unless @counter if @counter < @history.size-1 @counter = @counter + 1 end @history[@counter] end |