class DataPoint
Public Class Methods
new(h={ :x => 0, :y => 0 })
click to toggle source
# File lib/technical_graph/data_point.rb, line 3 def initialize(h={ :x => 0, :y => 0 }) if h.kind_of? Hash @x = h[:x] @y = h[:y] end if h.kind_of? DataPoint @x = h.x @y = h.y end end
xy(_x, _y)
click to toggle source
# File lib/technical_graph/data_point.rb, line 14 def self.xy(_x, _y) DataPoint.new({ :x=>_x, :y=>_y }) end
Public Instance Methods
x()
click to toggle source
# File lib/technical_graph/data_point.rb, line 26 def x @x end
x=(_x)
click to toggle source
# File lib/technical_graph/data_point.rb, line 34 def x=(_x) @x = _x end
x_distance(other_dp)
click to toggle source
# File lib/technical_graph/data_point.rb, line 18 def x_distance(other_dp) return (self.x - other_dp.x).abs end
y()
click to toggle source
# File lib/technical_graph/data_point.rb, line 30 def y @y end
y=(_y)
click to toggle source
# File lib/technical_graph/data_point.rb, line 38 def y=(_y) @y = _y end
y_distance(other_dp)
click to toggle source
# File lib/technical_graph/data_point.rb, line 22 def y_distance(other_dp) return (self.y - other_dp.y).abs end