13 other and @x == other.x and @y == other.y
17 self.class.new(@x + other.x, @y + other.y)
21 self.class.new(@x - other.x, @y - other.y)
25 self.class.new(@x * factor, @y * factor)
29 self.class.new(@x / factor, @y / factor)
33 other.instance_of?(Point) and self == other
41 Point.new(@x.unit, @y.unit)
46 (((not other.x) or other.x == x) and
47 ((not other.y) or other.y == y))
51 "#{(x + ?a).chr if x}#{(ysize - y) if y}"
54 def self.from_coord(s, ysize)
55 if s =~ /^([a-zA-Z]?)(\d*)/
58 x = unless letter.empty?
65 y = ysize - number.to_i unless number.empty?
74 attr_reader :src, :dst, :delta
76 def initialize(src, dst)
80 @increment = @delta.unit
92 @delta.x == 0 or @delta.y == 0
96 @delta.x.abs == @delta.y.abs
100 parallel? or diagonal?