Class: HexaPDF::Content::Operator::BaseOperator
- Inherits:
-
Object
- Object
- HexaPDF::Content::Operator::BaseOperator
- Defined in:
- lib/hexapdf/content/operator.rb
Overview
A base class for operator implementations.
A default implementation for the #serialize method is provided. However, for performance reasons each operator should provide a custom #serialize method.
Direct Known Subclasses
AppendRectangle, ConcatenateMatrix, CurveTo, CurveToNoFirstControlPoint, CurveToNoSecondControlPoint, InlineImage, LineTo, MoveText, MoveTextAndSetLeading, MoveTextNextLineAndShowText, MoveTo, NoArgumentOperator, SetDeviceCMYKNonStrokingColor, SetDeviceCMYKStrokingColor, SetDeviceRGBNonStrokingColor, SetDeviceRGBStrokingColor, SetFontAndSize, SetGraphicsStateParameters, SetLineDashPattern, SetNonStrokingColor, SetNonStrokingColorSpace, SetRenderingIntent, SetSpacingMoveTextNextLineAndShowText, SetStrokingColor, SetStrokingColorSpace, SetTextMatrix, ShowText, ShowTextWithPositioning, SingleNumericArgumentOperator
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the operator.
Instance Method Summary collapse
-
#initialize(name) ⇒ BaseOperator
constructor
Initialize the operator called
name. -
#invoke ⇒ Object
Invokes the operator so that it performs its job.
-
#serialize(serializer, *operands) ⇒ Object
Returns the string representation of the operator, i.e.
Constructor Details
#initialize(name) ⇒ BaseOperator
Initialize the operator called name.
92 93 94 |
# File 'lib/hexapdf/content/operator.rb', line 92 def initialize(name) @name = name.freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the operator.
89 90 91 |
# File 'lib/hexapdf/content/operator.rb', line 89 def name @name end |
Instance Method Details
#invoke ⇒ Object
Invokes the operator so that it performs its job.
This base version does nothing!
99 100 |
# File 'lib/hexapdf/content/operator.rb', line 99 def invoke(*) end |
#serialize(serializer, *operands) ⇒ Object
Returns the string representation of the operator, i.e.
operand1 operand2 operand3 name
105 106 107 108 109 110 111 |
# File 'lib/hexapdf/content/operator.rb', line 105 def serialize(serializer, *operands) result = ''.b operands.each do |operand| result << serializer.serialize(operand) << " " end result << name << "\n" end |