Class: Prawn::SVG::Interface
- Inherits:
-
Object
- Object
- Prawn::SVG::Interface
- Defined in:
- lib/prawn/svg/interface.rb
Constant Summary collapse
- VALID_OPTIONS =
i[ at position vposition width height cache_images enable_web_requests enable_file_requests_with_root fallback_font_name color_mode ].freeze
- INHERITABLE_OPTIONS =
i[ enable_web_requests enable_file_requests_with_root cache_images fallback_font_name color_mode ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prawn ⇒ Object
readonly
Returns the value of attribute prawn.
Class Method Summary collapse
-
.font_path ⇒ Object
backwards support for when the font_path used to be stored on this class.
Instance Method Summary collapse
-
#draw ⇒ Object
Draws the SVG to the Prawn::Document object.
-
#initialize(data, prawn, options, &block) ⇒ Interface
constructor
Creates a Prawn::SVG object.
- #position ⇒ Object
- #resize(width: nil, height: nil) ⇒ Object
- #sizing ⇒ Object
Constructor Details
#initialize(data, prawn, options, &block) ⇒ Interface
Creates a Prawn::SVG object.
data
is the SVG data to convert. prawn
is your Prawn::Document object.
See README.md for the options that can be passed to this method.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/prawn/svg/interface.rb', line 27 def initialize(data, prawn, , &block) Prawn. VALID_OPTIONS, @data = data @prawn = prawn = font_registry = Prawn::SVG::FontRegistry.new(prawn.font_families) @document = Document.new( data, [prawn.bounds.width, prawn.bounds.height], , font_registry: font_registry, &block ) @renderer = Renderer.new(prawn, document, ) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
18 19 20 |
# File 'lib/prawn/svg/interface.rb', line 18 def data @data end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
18 19 20 |
# File 'lib/prawn/svg/interface.rb', line 18 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/prawn/svg/interface.rb', line 18 def end |
#prawn ⇒ Object (readonly)
Returns the value of attribute prawn.
18 19 20 |
# File 'lib/prawn/svg/interface.rb', line 18 def prawn @prawn end |
Class Method Details
.font_path ⇒ Object
backwards support for when the font_path used to be stored on this class
64 65 66 |
# File 'lib/prawn/svg/interface.rb', line 64 def self.font_path Prawn::SVG::FontRegistry.font_path end |
Instance Method Details
#draw ⇒ Object
Draws the SVG to the Prawn::Document object.
47 48 49 |
# File 'lib/prawn/svg/interface.rb', line 47 def draw @renderer.draw end |
#position ⇒ Object
59 60 61 |
# File 'lib/prawn/svg/interface.rb', line 59 def position @renderer.position end |
#resize(width: nil, height: nil) ⇒ Object
55 56 57 |
# File 'lib/prawn/svg/interface.rb', line 55 def resize(width: nil, height: nil) document.calculate_sizing(requested_width: width, requested_height: height) end |
#sizing ⇒ Object
51 52 53 |
# File 'lib/prawn/svg/interface.rb', line 51 def sizing document.sizing end |