Module: Sketch::DSL

Included in:
Builder
Defined in:
lib/sketch/dsl.rb

Accessors collapse

Instance Method Summary collapse

Instance Attribute Details

#firstObject (readonly)



12
13
14
# File 'lib/sketch/dsl.rb', line 12

def first
    elements.first
end

#lastObject (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

Returns:

  • (RegularPolygon)


25
26
27
28
# File 'lib/sketch/dsl.rb', line 25

def hexagon(options={})
    options[:sides] = 6
    Geometry::RegularPolygon.new(options).tap {|a| push a }
end

#layout(direction, *args, &block) ⇒ Group

Create a layout

Parameters:

  • direction (Symbol)

    The layout direction (either :horizontal or :vertical)

  • options (Hash)

    a customizable set of options

Returns:



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

Returns:



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