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 =
: PDF::Reader::Point
self.new(1, 1)
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
: Numeric.
-
#y ⇒ Object
readonly
: Numeric.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (PDF::Reader::Point) -> bool.
-
#initialize(x, y) ⇒ Point
constructor
: (Numeric, Numeric) -> void.
Constructor Details
#initialize(x, y) ⇒ Point
: (Numeric, Numeric) -> void
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)
: Numeric
14 15 16 |
# File 'lib/pdf/reader/point.rb', line 14 def x @x end |
#y ⇒ Object (readonly)
: Numeric
17 18 19 |
# File 'lib/pdf/reader/point.rb', line 17 def y @y end |
Instance Method Details
#==(other) ⇒ Object
: (PDF::Reader::Point) -> bool
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 |