class DrawSvg::Point
Attributes
x[RW]
y[RW]
Public Class Methods
[](*args)
click to toggle source
# File lib/drawsvg.rb, line 16 def self.[] *args Point.new(*args) end
new(x, y=nil)
click to toggle source
# File lib/drawsvg.rb, line 20 def initialize x, y=nil if !y.nil? @x, @y = x, y elsif x.is_a? Array and x.size == 2 @x, @y = x[0], x[1] elsif x.is_a? Point @x, @y = x.x, x.y else @x, @y = x, x end end
Public Instance Methods
*(other)
click to toggle source
# File lib/drawsvg.rb, line 39 def * other other = Point.new(other) Point.new(@x*other.x, @y*other.y) end
+(other)
click to toggle source
# File lib/drawsvg.rb, line 31 def + other other = Point.new(other) Point.new(@x+other.x, @y+other.y) end
-(other)
click to toggle source
# File lib/drawsvg.rb, line 35 def - other other = Point.new(other) Point.new(@x-other.x, @y-other.y) end
round()
click to toggle source
# File lib/drawsvg.rb, line 43 def round Point.new(@x.round, @y.round) end
to_s()
click to toggle source
# File lib/drawsvg.rb, line 46 def to_s "[#{@x}, #{@y}]" end