Class: TaskJuggler::Painter::Element
- Includes:
- Primitives, SVGSupport
- Defined in:
- lib/taskjuggler/Painter/Element.rb
Overview
The base class for all drawable elements.
Constant Summary
Constants included from Primitives
Primitives::FillAndStrokeAttrs, Primitives::FillAttrs, Primitives::StrokeAttrs, Primitives::TextAttrs
Instance Method Summary collapse
-
#initialize(type, attrs, values) ⇒ Element
constructor
Create a new Element.
-
#to_svg ⇒ Object
Convert the Element into an XMLElement tree using SVG syntax.
Methods included from Primitives
#circle, #color, #ellipse, #group, #line, #points, #polyline, #rect, #text
Methods included from SVGSupport
Constructor Details
#initialize(type, attrs, values) ⇒ Element
Create a new Element. type specifies the type of the element. attrs is a list of the supported attributes. values is a hash of the provided attributes.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/taskjuggler/Painter/Element.rb', line 30 def initialize(type, attrs, values) @type = type @attributes = attrs @values = {} @text = nil values.each do |k, v| unless @attributes.include?(k) raise ArgumentError, "Unsupported attribute #{k}" end @values[k] = v end end |
Instance Method Details
#to_svg ⇒ Object
Convert the Element into an XMLElement tree using SVG syntax.
45 46 47 48 49 |
# File 'lib/taskjuggler/Painter/Element.rb', line 45 def to_svg el = XMLElement.new(@type, valuesToSVG) el << XMLText.new(@text) if @text el end |