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