Class: PDF::Reader::Point
- Inherits:
-
Object
- Object
- PDF::Reader::Point
- Defined in:
- lib/pdf/reader/point.rb
Overview
PDFs are all about positioning content on a page, so there's lots of need to work with a set of X,Y coordinates.
Constant Summary collapse
- ZERO_ZERO =
These two points are super common, so make them available as constants to reduce object allocations. Points are immutable, so it's fine to have multiple code paths using the same object
self.new(0, 0)
- ONE_ONE =
self.new(1, 1)
Instance Attribute Summary collapse
- #x ⇒ Object readonly
- #y ⇒ Object readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(x, y) ⇒ Point
constructor
A new instance of Point.
Constructor Details
#initialize(x, y) ⇒ Point
Returns a new instance of Point.
20 21 22 23 |
# File 'lib/pdf/reader/point.rb', line 20 def initialize(x, y) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object (readonly)
14 15 16 |
# File 'lib/pdf/reader/point.rb', line 14 def x @x end |
#y ⇒ Object (readonly)
17 18 19 |
# File 'lib/pdf/reader/point.rb', line 17 def y @y end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'lib/pdf/reader/point.rb', line 26 def ==(other) other.respond_to?(:x) && other.respond_to?(:y) && x == other.x && y == other.y end |