Class: Wicket::Subpath
- Inherits:
-
Object
- Object
- Wicket::Subpath
- Defined in:
- lib/wicket/subpath.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Instance Method Summary collapse
- #add_command(*new_commands) ⇒ Object
- #closed? ⇒ Boolean
- #cursor_end ⇒ Object
- #first_command ⇒ Object
-
#initialize ⇒ Subpath
constructor
A new instance of Subpath.
- #last_command ⇒ Object
- #to_polygon(opts) ⇒ Object
- #to_svg(opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ Subpath
Returns a new instance of Subpath.
4 5 6 |
# File 'lib/wicket/subpath.rb', line 4 def initialize @commands = [] end |
Instance Attribute Details
#commands ⇒ Object (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
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_end ⇒ Object
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_command ⇒ Object
34 35 36 |
# File 'lib/wicket/subpath.rb', line 34 def first_command @commands.first end |
#last_command ⇒ Object
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 |