Class: PDF::Reader::CMap

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/cmap.rb

Overview

wraps a string containing a PDF CMap and provides convenience methods for extracting various useful information.

Constant Summary collapse

CMAP_KEYWORDS =

:nodoc:

{
  "begincodespacerange" => :noop,
  "endcodespacerange" => :noop,
  "beginbfchar" => :noop,
  "endbfchar" => :noop,
  "beginbfrange" => :noop,
  "endbfrange" => :noop,
  "begin" => :noop,
  "begincmap" => :noop,
  "def" => :noop
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CMap

: (String) -> void



53
54
55
56
# File 'lib/pdf/reader/cmap.rb', line 53

def initialize(data)
  @map = {} #: Hash[Integer, Array[Integer]]
  process_data(data)
end

Instance Attribute Details

#mapObject (readonly)

: Hash[Integer, Array]



50
51
52
# File 'lib/pdf/reader/cmap.rb', line 50

def map
  @map
end

Instance Method Details

#decode(c) ⇒ Object

Convert a glyph code into one or more Codepoints.

Returns an array of Integers.

: (Integer) -> Array



68
69
70
# File 'lib/pdf/reader/cmap.rb', line 68

def decode(c)
  @map.fetch(c, [])
end

#sizeObject

: () -> Integer



59
60
61
# File 'lib/pdf/reader/cmap.rb', line 59

def size
  @map.size
end