Module: Pdfrb::Content::Operator
- Defined in:
- lib/pdfrb/content/operator.rb,
lib/pdfrb/content/parser.rb,
lib/pdfrb/content/operators/path.rb,
lib/pdfrb/content/operators/color.rb,
lib/pdfrb/content/operators/general.rb,
lib/pdfrb/content/operators/clipping.rb,
lib/pdfrb/content/operators/painting.rb,
lib/pdfrb/content/operators/text_state.rb,
lib/pdfrb/content/operators/text_showing.rb,
lib/pdfrb/content/operators/marked_content.rb,
lib/pdfrb/content/operators/text_positioning.rb,
lib/pdfrb/content/operators/graphics_state_params.rb
Overview
Operator catalogue. Each PDF content operator (q, m, Tj,
...) is implemented by a subclass of Operator::Base that
registers itself in REGISTRY at file load.
Adding a new operator = adding one subclass + register. No
switch edits (open/closed). Mirrors the postscript gem's
Model::Operators pattern.
Defined Under Namespace
Classes: ApplyExtGState, Base, BeginMarkedContent, BeginMarkedContentWithProperties, BeginText, CharSpacing, ClipEvenOdd, ClipNonZero, CloseAndStroke, CloseFillStrokeEvenOdd, CloseFillStrokeNonZero, ClosePath, ConcatMatrix, CurveTo, CurveToFirstReflected, CurveToLastEqual, DashPattern, EndMarkedContent, EndPath, EndText, FillCMYK, FillDeprecatedAlias, FillEvenOdd, FillGray, FillNonZero, FillRGB, FillStrokeEvenOdd, FillStrokeNonZero, Flatness, Font, HorizontalScaling, InvokeXObject, Leading, LineCap, LineJoin, LineTo, LineWidth, MarkedContentPoint, MarkedContentPointWithProperties, MiterLimit, MoveTo, MoveToNextLineShowText, NextLine, NoArg, NonStrokeAlpha, Rectangle, RenderingIntent, RenderingMode, RestoreGraphicsState, Rise, SaveGraphicsState, SetFillColor, SetFillColorN, SetFillColorSpace, SetSpacingMoveToShowText, SetStrokeColor, SetStrokeColorN, SetStrokeColorSpace, SetTextMatrix, ShowText, ShowTextWithSpacing, Stroke, StrokeAlpha, StrokeCMYK, StrokeGray, StrokeRGB, TextTranslate, TextTranslateSetLeading, Unknown, WordSpacing
Class Attribute Summary collapse
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
- .[](name) ⇒ Object
-
.eager_load! ⇒ Object
Force-load all operator implementations so register calls fire and populate the registry.
- .names ⇒ Object
- .register(name, klass) ⇒ Object
Class Attribute Details
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
16 17 18 |
# File 'lib/pdfrb/content/operator.rb', line 16 def registry @registry end |
Class Method Details
.[](name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pdfrb/content/operator.rb', line 22 def [](name) key = name.to_s result = @registry[key] return result if result # Lazy-load on miss: trigger eager_load! which populates # the registry, then retry. eager_load! unless @eager_loaded @registry[key] end |
.eager_load! ⇒ Object
Force-load all operator implementations so register calls fire and populate the registry. Idempotent.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pdfrb/content/operator.rb', line 39 def eager_load! return if @eager_loaded Pdfrb::Content::Operators.constants.each do |c| Pdfrb::Content::Operators.const_get(c) rescue NameError # Skip modules that don't resolve. end @eager_loaded = true end |
.names ⇒ Object
33 34 35 |
# File 'lib/pdfrb/content/operator.rb', line 33 def names @registry.keys end |
.register(name, klass) ⇒ Object
18 19 20 |
# File 'lib/pdfrb/content/operator.rb', line 18 def register(name, klass) @registry[name.to_s] = klass end |