Class: TaskJuggler::Painter::Points
- Defined in:
- lib/taskjuggler/Painter/Points.rb
Overview
Utility class to describe a list of x, y coordinates. Each coordinate is an Array with 2 elements. The whole list is another Array.
Instance Method Summary collapse
-
#initialize(arr) ⇒ Points
constructor
Store the list after doing some error checking.
-
#to_s ⇒ Object
Conver the list of coordinates into a String that is compatible with SVG syntax.
Constructor Details
#initialize(arr) ⇒ Points
Store the list after doing some error checking.
23 24 25 26 27 28 29 30 |
# File 'lib/taskjuggler/Painter/Points.rb', line 23 def initialize(arr) arr.each do |point| unless point.is_a?(Array) && point.length == 2 raise ArgumentError, 'Points must be an Array with 2 coordinates' end end @points = arr end |
Instance Method Details
#to_s ⇒ Object
Conver the list of coordinates into a String that is compatible with SVG syntax.
34 35 36 37 38 39 40 |
# File 'lib/taskjuggler/Painter/Points.rb', line 34 def to_s str = '' @points.each do |point| str += "#{point[0]},#{point[1]} " end str end |