Class: Airsprite::Rect

Inherits:
Object
  • Object
show all
Defined in:
lib/airsprite/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height, offset_x, offset_y) ⇒ Rect

Returns a new instance of Rect.



150
151
152
153
154
155
# File 'lib/airsprite/base.rb', line 150

def initialize(width, height, offset_x, offset_y)
  @width = width
  @height = height
  @x = offset_x
  @y = offset_y
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



148
149
150
# File 'lib/airsprite/base.rb', line 148

def height
  @height
end

#widthObject

Returns the value of attribute width.



148
149
150
# File 'lib/airsprite/base.rb', line 148

def width
  @width
end

#xObject

Returns the value of attribute x.



148
149
150
# File 'lib/airsprite/base.rb', line 148

def x
  @x
end

#yObject

Returns the value of attribute y.



148
149
150
# File 'lib/airsprite/base.rb', line 148

def y
  @y
end

Instance Method Details

#areaObject



157
158
159
# File 'lib/airsprite/base.rb', line 157

def area
  width * height
end

#to_sObject



161
162
163
# File 'lib/airsprite/base.rb', line 161

def to_s
  "rect: #{width} x #{height} = #{area} (#{x}, #{y})"
end