Class: RPDF::PDFName

Inherits:
PDFObject show all
Defined in:
lib/rpdf/pdfname.rb

Overview

Name Object

PDFRef15 p32

Instance Attribute Summary collapse

Attributes inherited from PDFObject

#generation_number, #object_number

Instance Method Summary collapse

Methods inherited from PDFObject

#indirect?, #invalidate, #invalidated?, #to_pdf, #to_ref

Constructor Details

#initialize(value, document = nil) ⇒ PDFName

Returns a new instance of PDFName.

Raises:

  • (Exception)


11
12
13
14
15
16
17
# File 'lib/rpdf/pdfname.rb', line 11

def initialize(value, document=nil)
  raise Exception.new("PDFName is not a string") unless value.kind_of?(String)
  raise Exception.new("PDFName has whitespace") if RPDF.includes_whitespace?(value)
  raise Exception.new("PDFName has delimiter") if RPDF.includes_delimiter?(value)
  @value = value
  super(document)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/rpdf/pdfname.rb', line 9

def value
  @value
end

Instance Method Details

#eql?(other) ⇒ Boolean

To make PDFName possible to use as a key in a PDFDictionary

Returns:

  • (Boolean)


24
25
26
# File 'lib/rpdf/pdfname.rb', line 24

def eql?(other)
  @value.eql?(other.value)
end

#hashObject



19
20
21
# File 'lib/rpdf/pdfname.rb', line 19

def hash
  @value.hash
end

#to_sObject

TODO: 2-digit hexadecimal code for characters outside the range 33 (!) to 126 (~) [PDFRef15 p33]



29
30
31
# File 'lib/rpdf/pdfname.rb', line 29

def to_s
  "/#{@value}"
end