Class: Sketch::Canvas
- Inherits:
-
Valuable
- Object
- Valuable
- Sketch::Canvas
- Includes:
- Base
- Defined in:
- lib/sketch/canvas.rb
Instance Method Summary collapse
- #builder ⇒ Object
- #default_doctype ⇒ Object
- #namespace_bindings ⇒ Object
- #render_doctype(document) ⇒ Object
- #svg_attributes ⇒ Object
Instance Method Details
#builder ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sketch/canvas.rb', line 17 def builder Nokogiri::XML::Builder.new do |document| render_doctype( document ) document.svg( svg_attributes ) {|svg| yield svg if block_given?} end end |
#default_doctype ⇒ Object
24 25 26 |
# File 'lib/sketch/canvas.rb', line 24 def default_doctype ['svg', "-//W3C//DTD SVG 1.0//EN", "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"] end |
#namespace_bindings ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/sketch/canvas.rb', line 9 def namespace_bindings { 'xmlns' => 'http://www.w3.org/2000/svg', 'xmlns:ev' => 'http://www.w3.org/2001/xml-events', 'xmlns:xlink' => 'http://www.w3.org/1999/xlink' } end |
#render_doctype(document) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/sketch/canvas.rb', line 28 def render_doctype( document ) self.doctype &&= self.default_doctype if( self.doctype ) document.doc.create_internal_subset(*self.doctype) end end |
#svg_attributes ⇒ Object
36 37 38 39 40 |
# File 'lib/sketch/canvas.rb', line 36 def svg_attributes atts = super atts.delete('doctype') atts.merge(namespace_bindings) end |