Class: PDF::Reader::Point

Inherits:
Object
  • Object
show all
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 =

Signature:

  • PDF::Reader::Point

self.new(1, 1)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

Returns a new instance of Point.

Signature:

  • (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

#xObject (readonly)

Signature:

  • Numeric



14
15
16
# File 'lib/pdf/reader/point.rb', line 14

def x
  @x
end

#yObject (readonly)

Signature:

  • Numeric



17
18
19
# File 'lib/pdf/reader/point.rb', line 17

def y
  @y
end

Instance Method Details

#==(other) ⇒ Object

Signature:

  • (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