Class: Postscript::Model::Operators::Font::Stringwidth

Inherits:
Postscript::Model::Operator show all
Defined in:
lib/postscript/model/operators/font.rb

Overview

Returns the width of text under the current font (in thousandths of a unit, divided by 1000). The visitor pushes [x, y] onto the stack.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Postscript::Model::Operator

#accept, #operator?, register_as

Constructor Details

#initialize(text:) ⇒ Stringwidth

Returns a new instance of Stringwidth.



93
94
95
96
# File 'lib/postscript/model/operators/font.rb', line 93

def initialize(text:)
  @text = text
  freeze
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



92
93
94
# File 'lib/postscript/model/operators/font.rb', line 92

def text
  @text
end

Class Method Details

.from_operands(stack) ⇒ Object



97
98
99
# File 'lib/postscript/model/operators/font.rb', line 97

def self.from_operands(stack)
  new(text: stack.pop)
end