Class: Linear1::PointSlope

Inherits:
Function show all
Defined in:
lib/linear1/point_slope.rb

Instance Attribute Summary collapse

Attributes inherited from Function

#power, #slope, #y_intercept

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

#direct_variation?, display_num, #execute, #to_direct_variation, #to_function, #to_s, #x_intercept

Constructor Details

#initialize(x, y, slope) ⇒ PointSlope

Returns a new instance of PointSlope



6
7
8
9
# File 'lib/linear1/point_slope.rb', line 6

def initialize x, y, slope
  @slope, @x1, @y1 = display_num(slope), display_num(x), display_num(y)
  super @slope, @x1 - @y1
end

Instance Attribute Details

#x1Object (readonly)

Returns the value of attribute x1



5
6
7
# File 'lib/linear1/point_slope.rb', line 5

def x1
  @x1
end

#y1Object (readonly)

Returns the value of attribute y1



5
6
7
# File 'lib/linear1/point_slope.rb', line 5

def y1
  @y1
end

Class Method Details

.try_convert(object) ⇒ Object

Raises:

  • (TypeError)


11
12
13
14
15
16
# File 'lib/linear1/point_slope.rb', line 11

def try_convert object
  for sym in i(to_point_slope to_ps)
    return object.send(sym) if object.respond_to? sym
  end
  raise TypeError, "Unable to convert #{object} to PointSlope"
end

Instance Method Details

#to_slope_interceptObject Also known as: to_si



18
19
20
21
# File 'lib/linear1/point_slope.rb', line 18

def to_slope_intercept
  require "linear1/slope_intercept"
  SlopeIntercept slope, y_intercept
end

#to_standardObject



23
24
25
# File 'lib/linear1/point_slope.rb', line 23

def to_standard
  to_si.to_standard
end