Class: XYP::Point

Inherits:
Struct
  • Object
show all
Defined in:
lib/xyp/plot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



21
22
23
# File 'lib/xyp/plot.rb', line 21

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



21
22
23
# File 'lib/xyp/plot.rb', line 21

def y
  @y
end

Instance Method Details

#+(other) ⇒ Object



26
27
28
# File 'lib/xyp/plot.rb', line 26

def +(other)
  Point.new(self.x+other.x,self.y+other.y)
end

#-(other) ⇒ Object



22
23
24
# File 'lib/xyp/plot.rb', line 22

def -(other)
  Point.new(self.x-other.x,self.y-other.y)
end

#to_aObject



34
35
36
# File 'lib/xyp/plot.rb', line 34

def to_a
  [x,y]
end

#to_iObject



30
31
32
# File 'lib/xyp/plot.rb', line 30

def to_i
  Point.new(x.to_i,y.to_i)
end