Sha256: 76c6d773ad2b983e828d254de48b6c68ccdc326290d8ee596d6b024485ec7e43

Contents?: true

Size: 666 Bytes

Versions: 6

Compression:

Stored size: 666 Bytes

Contents

require_relative "dotter"

module Vamp
  module Graphic
    # simple sample implementation for a graphic basic implementation
    class TextDotter < Dotter
      def dot(x, y)
        super
        @data[y][x] = "X"
        self
      end

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vamp-0.2.0 lib/vamp/graphic/text_dotter.rb
vamp-0.1.8 lib/vamp/graphic/text_dotter.rb
vamp-0.1.7 lib/vamp/graphic/text_dotter.rb
vamp-0.1.6 lib/vamp/graphic/text_dotter.rb
vamp-0.1.5 lib/vamp/graphic/text_dotter.rb
vamp-0.1.4 lib/vamp/graphic/text_dotter.rb