Class: HexaPDF::Content::Operator::BaseOperator
- Inherits:
-
Object
- Object
- HexaPDF::Content::Operator::BaseOperator
- Defined in:
- lib/hexapdf/content/operator.rb
Overview
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
.
90 91 92 |
# File 'lib/hexapdf/content/operator.rb', line 90 def initialize(name) @name = name.freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the operator.
87 88 89 |
# File 'lib/hexapdf/content/operator.rb', line 87 def name @name end |
Instance Method Details
#invoke ⇒ Object
Invokes the operator so that it performs its job.
This base version does nothing!
97 98 |
# File 'lib/hexapdf/content/operator.rb', line 97 def invoke(*) end |
#serialize(serializer, *operands) ⇒ Object
Returns the string representation of the operator, i.e.
operand1 operand2 operand3 name
103 104 105 106 107 108 109 |
# File 'lib/hexapdf/content/operator.rb', line 103 def serialize(serializer, *operands) result = ''.b operands.each do |operand| result << serializer.serialize(operand) << " " end result << name << "\n" end |