class TaskJuggler::Painter::Element

The base class for all drawable elements.

Public Class Methods

new(type, attrs, values) click to toggle source

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.

# 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

Public Instance Methods

to_svg() click to toggle source

Convert the Element into an XMLElement tree using SVG syntax.

# File lib/taskjuggler/Painter/Element.rb, line 45
def to_svg
  el = XMLElement.new(@type, valuesToSVG)
  el << XMLText.new(@text) if @text
  el
end