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.



6
7
8
9
# File 'lib/aims_project/geometry_console.rb', line 6

def initialize
  @history= []
  @counter = 0
end

Instance Method Details

#prevObject



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

#succObject



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