Class: Pdfrb::Model::Rectangle
- Inherits:
-
Object
- Object
- Pdfrb::Model::Rectangle
- Defined in:
- lib/pdfrb/model/rectangle.rb
Overview
PDF rectangle (s7.9.5): 4-number array [llx lly urx ury].
Immutable value object.
Instance Attribute Summary collapse
-
#llx ⇒ Object
readonly
Returns the value of attribute llx.
-
#lly ⇒ Object
readonly
Returns the value of attribute lly.
-
#urx ⇒ Object
readonly
Returns the value of attribute urx.
-
#ury ⇒ Object
readonly
Returns the value of attribute ury.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #bottom ⇒ Object
- #corner ⇒ Object
- #hash ⇒ Object
- #height ⇒ Object
-
#initialize(llx, lly, urx, ury) ⇒ Rectangle
constructor
A new instance of Rectangle.
- #inspect ⇒ Object
- #left ⇒ Object
- #origin ⇒ Object
- #right ⇒ Object
- #to_a ⇒ Object
- #top ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(llx, lly, urx, ury) ⇒ Rectangle
Returns a new instance of Rectangle.
10 11 12 13 14 15 16 |
# File 'lib/pdfrb/model/rectangle.rb', line 10 def initialize(llx, lly, urx, ury) @llx = llx.to_f @lly = lly.to_f @urx = urx.to_f @ury = ury.to_f freeze end |
Instance Attribute Details
#llx ⇒ Object (readonly)
Returns the value of attribute llx.
8 9 10 |
# File 'lib/pdfrb/model/rectangle.rb', line 8 def llx @llx end |
#lly ⇒ Object (readonly)
Returns the value of attribute lly.
8 9 10 |
# File 'lib/pdfrb/model/rectangle.rb', line 8 def lly @lly end |
#urx ⇒ Object (readonly)
Returns the value of attribute urx.
8 9 10 |
# File 'lib/pdfrb/model/rectangle.rb', line 8 def urx @urx end |
#ury ⇒ Object (readonly)
Returns the value of attribute ury.
8 9 10 |
# File 'lib/pdfrb/model/rectangle.rb', line 8 def ury @ury end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
40 41 42 |
# File 'lib/pdfrb/model/rectangle.rb', line 40 def ==(other) other.is_a?(Rectangle) && to_a == other.to_a end |
#bottom ⇒ Object
29 |
# File 'lib/pdfrb/model/rectangle.rb', line 29 def bottom; @lly; end |
#corner ⇒ Object
34 |
# File 'lib/pdfrb/model/rectangle.rb', line 34 def corner; [@urx, @ury]; end |
#hash ⇒ Object
45 46 47 |
# File 'lib/pdfrb/model/rectangle.rb', line 45 def hash to_a.hash end |
#height ⇒ Object
27 |
# File 'lib/pdfrb/model/rectangle.rb', line 27 def height; @ury - @lly; end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/pdfrb/model/rectangle.rb', line 49 def inspect "#<Rectangle llx=#{@llx} lly=#{@lly} urx=#{@urx} ury=#{@ury}>" end |
#left ⇒ Object
28 |
# File 'lib/pdfrb/model/rectangle.rb', line 28 def left; @llx; end |
#origin ⇒ Object
33 |
# File 'lib/pdfrb/model/rectangle.rb', line 33 def origin; [@llx, @lly]; end |
#right ⇒ Object
30 |
# File 'lib/pdfrb/model/rectangle.rb', line 30 def right; @urx; end |
#to_a ⇒ Object
36 37 38 |
# File 'lib/pdfrb/model/rectangle.rb', line 36 def to_a [@llx, @lly, @urx, @ury] end |
#top ⇒ Object
31 |
# File 'lib/pdfrb/model/rectangle.rb', line 31 def top; @ury; end |
#width ⇒ Object
26 |
# File 'lib/pdfrb/model/rectangle.rb', line 26 def width; @urx - @llx; end |