Class: Box
- Inherits:
-
Object
- Object
- Box
- Defined in:
- lib/box_layout.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#right ⇒ Object
Returns the value of attribute right.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #==(o) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(x, y, right, bottom) ⇒ Box
constructor
A new instance of Box.
- #inspect ⇒ Object
Constructor Details
#initialize(x, y, right, bottom) ⇒ Box
Returns a new instance of Box.
7 8 9 |
# File 'lib/box_layout.rb', line 7 def initialize(x, y, right, bottom) @x, @y, @right, @bottom = x, y, right, bottom end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
6 7 8 |
# File 'lib/box_layout.rb', line 6 def bottom @bottom end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/box_layout.rb', line 6 def right @right end |
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/box_layout.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/box_layout.rb', line 6 def y @y end |
Instance Method Details
#==(o) ⇒ Object Also known as: eql?
11 12 13 |
# File 'lib/box_layout.rb', line 11 def == o x = o.x and y = o.y and right == o.right and bottom == o.bottom end |
#hash ⇒ Object
16 17 18 |
# File 'lib/box_layout.rb', line 16 def hash [x, y, right, bottom].hash end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/box_layout.rb', line 20 def inspect "Box[x=%d, y=%d, r=%d, b=%d]" % [x, y, right, bottom] end |