Class: Savage::Path
Instance Attribute Summary collapse
Instance Method Summary
collapse
#rotate, #scale, #skew_x, #skew_y, #translate
included
Methods included from Utils
#bool_to_int
Constructor Details
#initialize(*args) {|_self| ... } ⇒ Path
Returns a new instance of Path.
18
19
20
21
22
|
# File 'lib/ext/savage/lib/savage/path.rb', line 18
def initialize(*args)
@subpaths = [SubPath.new]
@subpaths.last.move_to(*args) if (2..3).include?(*args.length)
yield self if block_given?
end
|
Instance Attribute Details
#subpaths ⇒ Object
Returns the value of attribute subpaths.
10
11
12
|
# File 'lib/ext/savage/lib/savage/path.rb', line 10
def subpaths
@subpaths
end
|
Instance Method Details
#closed? ⇒ Boolean
38
39
40
|
# File 'lib/ext/savage/lib/savage/path.rb', line 38
def closed?
@subpaths.last.closed?
end
|
#directions ⇒ Object
24
25
26
27
28
|
# File 'lib/ext/savage/lib/savage/path.rb', line 24
def directions
directions = []
@subpaths.each { |subpath| directions.concat(subpath.directions) }
directions
end
|
#move_to(*args) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/ext/savage/lib/savage/path.rb', line 30
def move_to(*args)
unless (@subpaths.last.directions.empty?)
(@subpaths << SubPath.new(*args)).last
else
@subpaths.last.move_to(*args)
end
end
|
#to_command ⇒ Object
42
43
44
|
# File 'lib/ext/savage/lib/savage/path.rb', line 42
def to_command
@subpaths.collect { |subpath| subpath.to_command }.join
end
|
46
47
48
|
# File 'lib/ext/savage/lib/savage/path.rb', line 46
def transform(*args)
@subpaths.each {|subpath| subpath.transform *args }
end
|