Class: Fir::Eraser

Inherits:
Object
  • Object
show all
Includes:
ScreenHelper
Defined in:
lib/fir/eraser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ScreenHelper

#clear, #cursor_back, #horizontal_absolute, #line_prompt, #next_line, #previous_line

Constructor Details

#initialize(output) ⇒ Eraser

Returns a new instance of Eraser.



12
13
14
# File 'lib/fir/eraser.rb', line 12

def initialize(output)
  @output = output
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/fir/eraser.rb', line 10

def output
  @output
end

Instance Method Details

#perform(state) ⇒ Object



16
17
18
19
20
21
# File 'lib/fir/eraser.rb', line 16

def perform(state)
  state.lines.length.times do |i|
    output.syswrite("#{horizontal_absolute(1)}#{clear(0)}")
    output.syswrite("#{previous_line(1)}#{clear(0)}") unless i.zero?
  end
end