class SvgPathify::Shape

Attributes

node[RW]
path[RW]
special_attrs[RW]

Public Class Methods

inherited( clz ) click to toggle source
# File lib/svg_pathify/shape.rb, line 30
def self.inherited( clz )
  def clz.special_attr( *attrs )
    class_eval do 
      attr_accessor *attrs

      define_method :attributes_to_delete do
        attrs.map &:to_s
      end

      define_method :special_attrs do
        attrs
      end

      attrs.each do |the_attr|
        define_method the_attr do
          instance_variable_get( "@#{the_attr}" ).to_short_f
        end
      end

    end
  end
end
new( node ) click to toggle source
# File lib/svg_pathify/shape.rb, line 7
def initialize( node )
  @node = node
  special_attrs && special_attrs.each do |attr|
    self.send "#{attr}=", node[attr]
  end
end

Public Instance Methods

attributes_to_delete() click to toggle source
# File lib/svg_pathify/shape.rb, line 26
def attributes_to_delete
  []
end
clean_attributes() click to toggle source
# File lib/svg_pathify/shape.rb, line 22
def clean_attributes
  node.attributes.reject {|k,v| attributes_to_delete.include?(k) }
end
path_commands() click to toggle source
# File lib/svg_pathify/shape.rb, line 18
def path_commands
  nil
end
to_path_element() click to toggle source
# File lib/svg_pathify/shape.rb, line 14
def to_path_element
  node.document.create_element 'path', clean_attributes.merge( d: path_commands )
end