Class: Prawn::SVG::Elements::Base
- Inherits:
-
Object
- Object
- Prawn::SVG::Elements::Base
- Extended by:
- Forwardable
- Includes:
- Attributes::ClipPath, Attributes::Opacity, Attributes::Space, Attributes::Stroke, Attributes::Transform, Calculators::Pixels, CallDuplicator, TransformParser
- Defined in:
- lib/prawn/svg/elements/base.rb
Direct Known Subclasses
Circle, ClipPath, Container, DirectRenderBase, Ellipse, Gradient, Ignored, Image, Line, Marker, Path, Polygon, Polyline, Rect, Root, 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::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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/prawn/svg/elements/base.rb', line 30 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.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def attributes @attributes end |
#base_calls ⇒ Object (readonly)
Returns the value of attribute base_calls.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def base_calls @base_calls end |
#calls ⇒ Object
Returns the value of attribute calls.
25 26 27 |
# File 'lib/prawn/svg/elements/base.rb', line 25 def calls @calls end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def document @document end |
#parent_calls ⇒ Object (readonly)
Returns the value of attribute parent_calls.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def parent_calls @parent_calls end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def properties @properties end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def source @source end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
24 25 26 |
# File 'lib/prawn/svg/elements/base.rb', line 24 def state @state end |
Instance Method Details
#name ⇒ Object
67 68 69 |
# File 'lib/prawn/svg/elements/base.rb', line 67 def name @name ||= source ? source.name : '???' end |
#parse_and_apply ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/prawn/svg/elements/base.rb', line 52 def parse_and_apply parse_standard_attributes parse apply_calls_from_standard_attributes apply 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
47 48 49 50 |
# File 'lib/prawn/svg/elements/base.rb', line 47 def process extract_attributes_and_properties parse_and_apply end |