Class: SVG::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-svg/misc.rb

Overview

#

Point Class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#xObject

Returns the value of attribute x.



20
21
22
# File 'lib/ruby-svg/misc.rb', line 20

def x
  @x
end

#yObject

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_sObject



32
33
34
# File 'lib/ruby-svg/misc.rb', line 32

def to_s
  return "#{@x} #{@y}"
end