Class: Sankey::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

Returns a new instance of Point.



5
6
7
8
# File 'lib/point.rb', line 5

def initialize(x, y)
  @x = x
  @y = y
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/point.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/point.rb', line 3

def y
  @y
end

Instance Method Details

#+(val) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/point.rb', line 10

def +(val)
  if val.is_a? Array and 2 == val.length
    x = val[0]
    y = val[1]
  else
    throw "Invalid argument"
  end
  Point.new @x + x, @y + y
end