class

PDF::Objects::Number

Inherits PDF::Objects::Base < Reference < Object

Represents a PDF numeric object (integer or real).

PDF supports both integer and real (floating-point) numbers. Integers are written without a decimal point. Reals are written with a decimal point and optional sign.

int = PDF::Objects::Number.new(42)
int.to_pdf # => "42"

real = PDF::Objects::Number.new(3.14159)
real.to_pdf # => "3.14159"

negative = PDF::Objects::Number.new(-17.5)
negative.to_pdf # => "-17.5"

Note: PDF reals have limited precision. Very small or very large values may lose precision when serialized.

Constants

MAX_DECIMAL_PLACES = 6

Maximum decimal places for real numbers

Constructors

new(value : Int)
Source
new(value : Float)
Source

Instance methods

==(other : self)

Returns true if this reference is the same as other. Invokes same?.

hash(hasher)

See Object#hash(hasher)

integer?

Returns true if this is an integer value

Source
real?

Returns true if this is a real (float) value

Source
to_f64

Returns the value as Float64

Source
to_i64

Returns the value as Int64, truncating if necessary

Source
to_pdf

Serializes this object to PDF syntax.

Returns the PDF representation as a string.

Source
value
Source