Module: Sketch::Base

Included in:
Canvas, Element
Defined in:
lib/sketch/base.rb

Instance Method Summary collapse

Instance Method Details

#svg_attributesObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sketch/base.rb', line 2

def svg_attributes
  out = {}

  #svg is heavy in dashes. Ruby symbols can't handle them.
  attributes.each do |name, value|
    next if name == :data
    out[name.to_s.gsub('_', '-')] = value
  end

  if attributes.has_key?( :data )
    attributes[:data].each do |name, value|
      out["data-#{name.to_s.gsub('_', '-')}"] = value
    end
  end

  out['class'] = out.delete('klass') if out.has_key?('klass')

  out
end