Class: SVG::Point
- Inherits:
-
Object
- Object
- SVG::Point
- Defined in:
- lib/ruby-svg/misc.rb
Overview
#
Point Class
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(x, y) ⇒ Point
constructor
A new instance of Point.
- #to_s ⇒ Object
Constructor Details
#initialize(x, y) ⇒ Point
Returns a new instance of Point.
15 16 17 18 |
# File 'lib/ruby-svg/misc.rb', line 15 def initialize(x, y) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
20 21 22 |
# File 'lib/ruby-svg/misc.rb', line 20 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
20 21 22 |
# File 'lib/ruby-svg/misc.rb', line 20 def y @y end |
Class Method Details
.[](*points) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby-svg/misc.rb', line 22 def self.[](*points) if points.size % 2 == 0 return (0...(points.size / 2)).collect { |i| self.new(points[i * 2], points[i * 2 + 1]) } else raise ArgumentError, 'odd number args for Point' end end |
Instance Method Details
#to_s ⇒ Object
32 33 34 |
# File 'lib/ruby-svg/misc.rb', line 32 def to_s return "#{@x} #{@y}" end |