Class: Postsvg::Renderer
- Inherits:
-
Object
- Object
- Postsvg::Renderer
- Defined in:
- lib/postsvg/renderer.rb
Overview
Top-level orchestrator for PS -> SVG. Owns lifecycle: BoundingBox pre-scan, builder open/close, visitor dispatch.
Constant Summary collapse
- MAX_OUTPUT_BYTES =
100 * 1024 * 1024
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#program ⇒ Object
readonly
Returns the value of attribute program.
-
#visitor ⇒ Object
readonly
Returns the value of attribute visitor.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(program, options) ⇒ Renderer
constructor
A new instance of Renderer.
Constructor Details
#initialize(program, options) ⇒ Renderer
Returns a new instance of Renderer.
15 16 17 18 19 20 21 22 |
# File 'lib/postsvg/renderer.rb', line 15 def initialize(program, ) raise ArgumentError, "program must be a Model::Program" unless program.is_a?(Model::Program) @program = program @options = @builder = SvgBuilder.new @visitor = Visitors::PsVisitor.new(builder: @builder) end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
13 14 15 |
# File 'lib/postsvg/renderer.rb', line 13 def builder @builder end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/postsvg/renderer.rb', line 13 def @options end |
#program ⇒ Object (readonly)
Returns the value of attribute program.
13 14 15 |
# File 'lib/postsvg/renderer.rb', line 13 def program @program end |
#visitor ⇒ Object (readonly)
Returns the value of attribute visitor.
13 14 15 |
# File 'lib/postsvg/renderer.rb', line 13 def visitor @visitor end |
Class Method Details
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/postsvg/renderer.rb', line 24 def call open_svg wrap_y_flip do visitor.visit_program(program) rescue Postsvg::QuitSignal # PS +quit+ ends program execution; suppress and finalize SVG. end builder.close_svg result = builder.to_s enforce_size_limit(result) result end |