Class: Treemap::Rectangle
- Inherits:
-
Object
- Object
- Treemap::Rectangle
- Defined in:
- lib/treemap/rectangle.rb
Instance Attribute Summary collapse
-
#x1 ⇒ Object
Returns the value of attribute x1.
-
#x2 ⇒ Object
Returns the value of attribute x2.
-
#y1 ⇒ Object
Returns the value of attribute y1.
-
#y2 ⇒ Object
Returns the value of attribute y2.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(x1, y1, x2, y2) {|_self| ... } ⇒ Rectangle
constructor
A new instance of Rectangle.
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(x1, y1, x2, y2) {|_self| ... } ⇒ Rectangle
Returns a new instance of Rectangle.
17 18 19 20 21 22 23 24 |
# File 'lib/treemap/rectangle.rb', line 17 def initialize(x1, y1, x2, y2) @x1 = x1 @y1 = y1 @x2 = x2 @y2 = y2 yield self if block_given? end |
Instance Attribute Details
#x1 ⇒ Object
Returns the value of attribute x1.
15 16 17 |
# File 'lib/treemap/rectangle.rb', line 15 def x1 @x1 end |
#x2 ⇒ Object
Returns the value of attribute x2.
15 16 17 |
# File 'lib/treemap/rectangle.rb', line 15 def x2 @x2 end |
#y1 ⇒ Object
Returns the value of attribute y1.
15 16 17 |
# File 'lib/treemap/rectangle.rb', line 15 def y1 @y1 end |
#y2 ⇒ Object
Returns the value of attribute y2.
15 16 17 |
# File 'lib/treemap/rectangle.rb', line 15 def y2 @y2 end |
Instance Method Details
#height ⇒ Object
34 35 36 |
# File 'lib/treemap/rectangle.rb', line 34 def height @y2 - @y1 end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/treemap/rectangle.rb', line 26 def to_s "[" + [@x1, @y1, @x2, @y2].join(",") + "]" end |
#width ⇒ Object
30 31 32 |
# File 'lib/treemap/rectangle.rb', line 30 def width @x2 - @x1 end |