Class: Wicket::Subpath

Inherits:
Object
  • Object
show all
Defined in:
lib/wicket/subpath.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSubpath

Returns a new instance of Subpath.



4
5
6
# File 'lib/wicket/subpath.rb', line 4

def initialize
  @commands = []
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



3
4
5
# File 'lib/wicket/subpath.rb', line 3

def commands
  @commands
end

Instance Method Details

#add_command(*new_commands) ⇒ Object



8
9
10
11
12
13
# File 'lib/wicket/subpath.rb', line 8

def add_command(*new_commands)
  new_commands.each do |c|
    @commands << c
  end
  self
end

#closed?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/wicket/subpath.rb', line 20

def closed?
  return false if @commands.empty?
  @commands.last.class == Commands::Z
end

#cursor_endObject



15
16
17
18
# File 'lib/wicket/subpath.rb', line 15

def cursor_end
  return {:x => 0, :y => 0} unless last_command
  last_command.cursor_end
end

#first_commandObject



34
35
36
# File 'lib/wicket/subpath.rb', line 34

def first_command
  @commands.first
end

#last_commandObject



30
31
32
# File 'lib/wicket/subpath.rb', line 30

def last_command
  @commands.last
end

#to_polygon(opts) ⇒ Object



25
26
27
28
# File 'lib/wicket/subpath.rb', line 25

def to_polygon(opts)
  vertices = commands.map{|c| c.to_wkt(opts) }.compact.join(",")
  "((#{vertices}))"
end

#to_svg(opts = {}) ⇒ Object



38
39
40
# File 'lib/wicket/subpath.rb', line 38

def to_svg(opts={})
  @commands.map{|c| c.to_svg(opts) }.join(" ")
end