Module: Postsvg::Model::Operators

Defined in:
lib/postsvg/model/operators.rb,
lib/postsvg/model/operators/font.rb,
lib/postsvg/model/operators/path.rb,
lib/postsvg/model/operators/color.rb,
lib/postsvg/model/operators/stack.rb,
lib/postsvg/model/operators/device.rb,
lib/postsvg/model/operators/boolean.rb,
lib/postsvg/model/operators/painting.rb,
lib/postsvg/model/operators/container.rb,
lib/postsvg/model/operators/arithmetic.rb,
lib/postsvg/model/operators/dictionary.rb,
lib/postsvg/model/operators/control_flow.rb,
lib/postsvg/model/operators/graphics_state.rb,
lib/postsvg/model/operators/transformations.rb

Overview

PS operator catalogue. Each subclass of Model::Operator registers itself under its keyword. The parser looks keywords up here to decide which class to instantiate.

Categories (mirrors PLRM chapter structure):

  • Stack, Arithmetic, Boolean, Path, Painting, Color, GraphicsState, Transformations, Dictionary, ControlFlow, Device

Defined Under Namespace

Modules: Arithmetic, Boolean, Color, Container, ControlFlow, Device, Dictionary, Font, GraphicsState, Painting, Path, Stack, Transformations

Class Method Summary collapse

Class Method Details

.[](keyword) ⇒ Object

Lookup by PS keyword. Returns nil for unknown keywords.



37
38
39
# File 'lib/postsvg/model/operators.rb', line 37

def [](keyword)
  @registry[keyword]
end

.keywordsObject



45
46
47
# File 'lib/postsvg/model/operators.rb', line 45

def keywords
  @registry.keys
end

.load_all!Object

Force-load every operator category so the registry is fully populated. Call this once before relying on [+].



51
52
53
# File 'lib/postsvg/model/operators.rb', line 51

def load_all!
  constants.each { |c| const_get(c) }
end

.register(keyword, klass) ⇒ Object



32
33
34
# File 'lib/postsvg/model/operators.rb', line 32

def register(keyword, klass)
  @registry[keyword] = klass
end

.registered?(keyword) ⇒ Boolean

Returns:



41
42
43
# File 'lib/postsvg/model/operators.rb', line 41

def registered?(keyword)
  @registry.key?(keyword)
end