Class: Square

Inherits:
Rectangle show all
Defined in:
lib/r2d/square.rb

Overview

square.rb

Instance Attribute Summary collapse

Attributes inherited from Rectangle

#height, #width, #x, #y

Attributes inherited from Quad

#c1, #c2, #c3, #c4, #color, #x1, #x2, #x3, #x4, #y1, #y2, #y3, #y4

Instance Method Summary collapse

Methods inherited from Rectangle

#gradient=

Methods inherited from Quad

#add, #remove

Constructor Details

#initialize(x = 0, y = 0, s = 100, c = "white", visible = true) ⇒ Square

Returns a new instance of Square.



7
8
9
10
11
12
13
# File 'lib/r2d/square.rb', line 7

def initialize(x=0, y=0, s=100, c="white", visible=true)
  @x, @y, @color = x, y, c
  @width = @height = @size = s
  update_coords(x, y, s, s)
  update_color(c)
  if visible then add end
end

Instance Attribute Details

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'lib/r2d/square.rb', line 5

def size
  @size
end