Class: Pdfrb::Color::ColorSpace

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfrb/color/color_space.rb

Overview

Color space value objects (ISO 32000-2 ยง8.6). Each color space knows how to serialize to its PDF representation (a name for device spaces, an array for CIE-based and special spaces).

Hierarchy:

Base
Device (DeviceGray, DeviceRGB, DeviceCMYK)
CIEBased (CalGray, CalRGB, Lab, ICCBased)
Special (Indexed, Separation, DeviceN, Pattern)

OCP: new color space = subclass + register_as.

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



27
28
29
# File 'lib/pdfrb/color/color_space.rb', line 27

def [](name)
  registry[name.to_sym]
end

.namesObject



31
32
33
# File 'lib/pdfrb/color/color_space.rb', line 31

def names
  registry.keys
end

.pdf_nameObject

Subclass hook: the PDF name or array-head symbol.

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/pdfrb/color/color_space.rb', line 36

def pdf_name
  raise NotImplementedError
end

.register(name, klass) ⇒ Object



23
24
25
# File 'lib/pdfrb/color/color_space.rb', line 23

def register(name, klass)
  registry[name.to_sym] = klass
end

.register_as(name = pdf_name) ⇒ Object

Register this class under its pdf_name.



41
42
43
44
# File 'lib/pdfrb/color/color_space.rb', line 41

def register_as(name = pdf_name)
  ColorSpace.register(name, self)
  self
end

.registryObject



19
20
21
# File 'lib/pdfrb/color/color_space.rb', line 19

def registry
  @registry ||= {}
end