Class: Sketch
- Inherits:
-
Valuable
show all
- Defined in:
- lib/sketch.rb
Defined Under Namespace
Modules: Base
Classes: Canvas, Circle, Element, Ellipse, Line, Path, Polygon, Rect, Star, Text, Triangle
Constant Summary
collapse
- Rectangle =
Sketch::Rect
Instance Method Summary
collapse
Instance Method Details
#draw(canvas) ⇒ Object
11
12
13
|
# File 'lib/sketch.rb', line 11
def draw(canvas)
raise NotImplementedError
end
|
#svg_attributes ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/sketch.rb', line 27
def svg_attributes
out = {}
out[:height] = self.height if self.height
out[:width] = self.width if self.width
out[:doctype] = self.doctype if self.doctype
out
end
|
#svg_builder ⇒ Object
35
36
37
|
# File 'lib/sketch.rb', line 35
def svg_builder
Canvas.new( svg_attributes ).builder {|canvas| yield canvas}
end
|
#to_html ⇒ Object
21
22
23
24
25
|
# File 'lib/sketch.rb', line 21
def to_html
svg_builder do |canvas|
self.draw( canvas )
end.doc.root.to_s
end
|
#to_svg ⇒ Object
15
16
17
18
19
|
# File 'lib/sketch.rb', line 15
def to_svg( )
svg_builder do |canvas|
self.draw( canvas )
end.to_xml
end
|