Module: Sketch::DSL
- Included in:
- Builder
- Defined in:
- lib/sketch/dsl.rb
Accessors collapse
- #first ⇒ Object readonly
- #last ⇒ Object readonly
Instance Method Summary collapse
-
#hexagon(options = {}) ⇒ RegularPolygon
Create a RegularPolygon with 6 sides.
-
#layout(direction, *args, &block) ⇒ Group
Create a layout.
-
#path(*args, &block) ⇒ Path
Create a Path.
-
#polygon(*args, &block) ⇒ Object
Create a Polygon with the given vertices, or using a block.
Instance Attribute Details
#first ⇒ Object (readonly)
12 13 14 |
# File 'lib/sketch/dsl.rb', line 12 def first elements.first end |
#last ⇒ Object (readonly)
18 19 20 |
# File 'lib/sketch/dsl.rb', line 18 def last elements.last end |
Instance Method Details
#hexagon(options = {}) ⇒ RegularPolygon
Create a RegularPolygon with 6 sides
25 26 27 28 |
# File 'lib/sketch/dsl.rb', line 25 def hexagon(={}) [:sides] = 6 Geometry::RegularPolygon.new().tap {|a| push a } end |
#layout(direction, *args, &block) ⇒ Group
Create a layout
35 36 37 |
# File 'lib/sketch/dsl.rb', line 35 def layout(direction, *args, &block) Builder.new(Layout.new(direction, *args)).evaluate(&block).tap {|a| push a} end |
#path(*args, &block) ⇒ Path
Create a Path
41 42 43 |
# File 'lib/sketch/dsl.rb', line 41 def path(*args, &block) Builder::Path.new(*args).evaluate(&block).tap {|a| push a } end |
#polygon(*args, &block) ⇒ Object
Create a Polygon with the given vertices, or using a block. See PolygonBuilder
47 48 49 50 51 52 53 54 |
# File 'lib/sketch/dsl.rb', line 47 def polygon(*args, &block) if block_given? push Builder::Polygon.new.evaluate(&block) else push Sketch::Polygon.new(*args) end last end |