Sha256: f02688183b5ce696c2e4fdbed352734d99254b93e53dcfede4d48bc336c80e5c

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

# Ruby2D::Square

module Ruby2D
  class Square < Rectangle

    attr_reader :size

    def initialize(opts = {})
      @x = opts[:x] || 0
      @y = opts[:y] || 0
      @z = opts[:z] || 0
      @width = @height = @size = opts[:size] || 100
      self.color = opts[:color] || 'white'
      update_coords(@x, @y, @size, @size)
      add
    end

    # Set the size of the square
    def size=(s)
      self.width = self.height = @size = s
    end

    # Make the inherited width and height attribute accessors private
    private :width=, :height=

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby2d-0.7.0 lib/ruby2d/square.rb
ruby2d-0.6.1 lib/ruby2d/square.rb
ruby2d-0.6.0 lib/ruby2d/square.rb