Sha256: 12a1b02005f0e4eed79a443a5ce8b239b7dbf658ed6986e7cf00e3dcd67a9620

Contents?: true

Size: 642 Bytes

Versions: 39

Compression:

Stored size: 642 Bytes

Contents

module GridGenerator
  class BaseElement
    def initialize(points:, colour: , opacity: 1)
      @points = points
      @colour = colour
      @opacity = opacity
    end

    attr_reader :points, :colour, :opacity

    def ==(other)
      self.class == other.class &&
        self.points == other.points &&
        self.colour == other.colour &&
        self.opacity == other.opacity
    end

    def points_string
      points.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
    end

    def as_json
      {
        "points_string" => points_string,
        "colour" => colour,
        "opacity" => opacity
      }
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
grid_generator-0.2.5 lib/grid_generator/base_element.rb
grid_generator-0.2.4 lib/grid_generator/base_element.rb
grid_generator-0.2.3 lib/grid_generator/base_element.rb
grid_generator-0.2.2 lib/grid_generator/base_element.rb
grid_generator-0.2.1 lib/grid_generator/base_element.rb
grid_generator-0.2.0 lib/grid_generator/base_element.rb
grid_generator-0.1.12 lib/grid_generator/base_element.rb
grid_generator-0.1.11 lib/grid_generator/base_element.rb
grid_generator-0.1.10 lib/grid_generator/base_element.rb
grid_generator-0.1.9 lib/grid_generator/base_element.rb
grid_generator-0.1.8 lib/grid_generator/base_element.rb
grid_generator-0.1.7 lib/grid_generator/base_element.rb
grid_generator-0.1.6 lib/grid_generator/base_element.rb
grid_generator-0.1.5 lib/grid_generator/base_element.rb
grid_generator-0.1.4 lib/grid_generator/base_element.rb
grid_generator-0.1.3 lib/grid_generator/base_element.rb
grid_generator-0.1.2 lib/grid_generator/base_element.rb
grid_generator-0.1.1 lib/grid_generator/base_element.rb
grid_generator-0.1.0 lib/grid_generator/base_element.rb