Class: Prawn::SVG::Elements::Base
- Inherits:
-
Object
- Object
- Prawn::SVG::Elements::Base
- Extended by:
- Forwardable
- Includes:
- Attributes::ClipPath, Attributes::Mask, Attributes::Opacity, Attributes::Space, Attributes::Stroke, Attributes::Transform, Calculators::Pixels, BboxScaling, CallDuplicator, TransformParser
- Defined in:
- lib/prawn/svg/elements/base.rb
Direct Known Subclasses
Anchor, Circle, ClipPath, Container, DirectRenderBase, Ellipse, Gradient, Ignored, Image, Line, Marker, Mask, Path, Pattern, Polygon, Polyline, Rect, Root, Switch, Use, Viewport
Constant Summary collapse
- PAINT_TYPES =
%w[fill stroke].freeze
- COMMA_WSP_REGEXP =
Prawn::SVG::Elements::COMMA_WSP_REGEXP
- SVG_NAMESPACE =
'http://www.w3.org/2000/svg'.freeze
- SkipElementQuietly =
Class.new(StandardError)
- SkipElementError =
Class.new(StandardError)
- MissingAttributesError =
Class.new(SkipElementError)
Constants included from Attributes::Stroke
Attributes::Stroke::CAP_STYLE_TRANSLATIONS, Attributes::Stroke::JOIN_STYLE_TRANSLATIONS
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#base_calls ⇒ Object
readonly
Returns the value of attribute base_calls.
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#parent_calls ⇒ Object
readonly
Returns the value of attribute parent_calls.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(document, source, parent_calls, state) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #parse_and_apply ⇒ Object
- #process ⇒ Object
Methods included from TransformParser
Methods included from PDFMatrix
#load_matrix, #matrix_for_pdf, #rotation_matrix, #scale_matrix, #translation_matrix
Methods included from Attributes::Space
Methods included from Attributes::Stroke
#parse_stroke_attributes_and_call
Methods included from Attributes::Mask
#parse_mask_attribute_and_call
Methods included from Attributes::ClipPath
#parse_clip_path_attribute_and_call
Methods included from Attributes::Opacity
#parse_opacity_attributes_and_call
Methods included from Attributes::Transform
#parse_transform_attribute_and_call
Constructor Details
#initialize(document, source, parent_calls, state) ⇒ Base
Returns a new instance of Base.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/prawn/svg/elements/base.rb', line 32 def initialize(document, source, parent_calls, state) @document = document @source = source @parent_calls = parent_calls @state = state @base_calls = @calls = [] @attributes = {} @properties = Prawn::SVG::Properties.new if source && add_to_elements_by_id? && !state.inside_use id = source.attributes['id'] id = id.strip if id document.elements_by_id[id] = self if id && id != '' end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def attributes @attributes end |
#base_calls ⇒ Object (readonly)
Returns the value of attribute base_calls.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def base_calls @base_calls end |
#calls ⇒ Object
Returns the value of attribute calls.
27 28 29 |
# File 'lib/prawn/svg/elements/base.rb', line 27 def calls @calls end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def document @document end |
#parent_calls ⇒ Object (readonly)
Returns the value of attribute parent_calls.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def parent_calls @parent_calls end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def properties @properties end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def source @source end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
26 27 28 |
# File 'lib/prawn/svg/elements/base.rb', line 26 def state @state end |
Instance Method Details
#name ⇒ Object
73 74 75 |
# File 'lib/prawn/svg/elements/base.rb', line 73 def name @name ||= source ? source.name : '???' end |
#parse_and_apply ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/prawn/svg/elements/base.rb', line 54 def parse_and_apply parse_standard_attributes parse apply_calls_from_standard_attributes apply if state.anchor_href && bounding_box add_call('svg:add_link', state.anchor_href, bounding_box) end process_child_elements if container? append_calls_to_parent unless computed_properties.display == 'none' rescue SkipElementQuietly rescue SkipElementError => e @document.warnings << e. end |
#process ⇒ Object
49 50 51 52 |
# File 'lib/prawn/svg/elements/base.rb', line 49 def process extract_attributes_and_properties parse_and_apply end |