Class: Rect
- Inherits:
-
Object
- Object
- Rect
- Defined in:
- lib/rgss3/rect.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #empty ⇒ Object
- #hash ⇒ Object
-
#initialize(*args) ⇒ Rect
constructor
A new instance of Rect.
- #set(*args) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(*args) ⇒ Rect
Returns a new instance of Rect.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rgss3/rect.rb', line 6 def initialize(*args) case args.size when 0 empty when 4 set(*args) else raise ArgumentError end end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/rgss3/rect.rb', line 4 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/rgss3/rect.rb', line 4 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/rgss3/rect.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/rgss3/rect.rb', line 4 def y @y end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
40 41 42 43 |
# File 'lib/rgss3/rect.rb', line 40 def ==(other) self.class == other.class && x == other.x && y == other.y && width == other.width && height == other.height end |
#empty ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rgss3/rect.rb', line 29 def empty @x = 0 @y = 0 @width = 0 @height = 0 end |
#hash ⇒ Object
47 48 49 |
# File 'lib/rgss3/rect.rb', line 47 def hash [:rect, *to_a].hash end |
#set(*args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rgss3/rect.rb', line 17 def set(*args) case args.size when 1 rect, = args @x, @y, @width, @height = *rect when 4 @x, @y, @width, @height = *args else raise ArgumentError end end |
#to_a ⇒ Object
36 37 38 |
# File 'lib/rgss3/rect.rb', line 36 def to_a [x, y, width, height] end |