Class: Vamp::Graphic::TextDotter

Inherits:
Dotter
  • Object
show all
Defined in:
lib/vamp/graphic/text_dotter.rb

Overview

simple sample implementation for a graphic basic implementation

Instance Attribute Summary

Attributes inherited from Dotter

#height, #width

Instance Method Summary collapse

Methods inherited from Dotter

#check, #in?, #initialize

Constructor Details

This class inherits a constructor from Vamp::Graphic::Dotter

Instance Method Details

#clearObject



24
25
26
27
# File 'lib/vamp/graphic/text_dotter.rb', line 24

def clear
  @data = Array.new(height) { Array.new(width, " ") }
  self
end

#dot(x, y) ⇒ Object



7
8
9
10
11
# File 'lib/vamp/graphic/text_dotter.rb', line 7

def dot(x, y)
  super
  @data[y][x] = "X"
  self
end

#dot?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/vamp/graphic/text_dotter.rb', line 13

def dot?(x, y)
  super
  @data[y][x] == "X"
end

#screenObject



29
30
31
32
# File 'lib/vamp/graphic/text_dotter.rb', line 29

def screen
  line = "+" + "-" * width + "+\n"
  line + @data.map { |x| "|#{x.join('')}|" }.join("\n").to_s + "\n" + line
end

#undot(x, y) ⇒ Object



18
19
20
21
22
# File 'lib/vamp/graphic/text_dotter.rb', line 18

def undot(x, y)
  super
  @data[y][x] = " "
  self
end