Class: HexaPDF::Layout::WidthFromPolygon
- Inherits:
-
Object
- Object
- HexaPDF::Layout::WidthFromPolygon
- Includes:
- Utils
- Defined in:
- lib/hexapdf/layout/width_from_polygon.rb
Overview
Utility class for generating width specifications for TextLayouter#fit from polygons.
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#call(height, line_height) ⇒ Object
Returns the width specification for the given values with respect to the wrapped polygon.
-
#initialize(polygon, offset = 0) ⇒ WidthFromPolygon
constructor
Creates a new object for the given polygon (or polygon set) and immediately prepares it so that #call can be used.
Constructor Details
#initialize(polygon, offset = 0) ⇒ WidthFromPolygon
Creates a new object for the given polygon (or polygon set) and immediately prepares it so that #call can be used.
The offset argument specifies the vertical offset from the top at which calculations should start.
52 53 54 55 |
# File 'lib/hexapdf/layout/width_from_polygon.rb', line 52 def initialize(polygon, offset = 0) @polygon = polygon prepare(offset) end |
Instance Method Details
#call(height, line_height) ⇒ Object
Returns the width specification for the given values with respect to the wrapped polygon.
58 59 60 |
# File 'lib/hexapdf/layout/width_from_polygon.rb', line 58 def call(height, line_height) width(@max_y - height - line_height, @max_y - height) end |