Class: AimsProject::CommandHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/aims_project/geometry_console.rb

Instance Method Summary collapse

Constructor Details

#initializeCommandHistory

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

#prevObject



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

#succObject



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