Class: Linear::SlopeIntercept
- Defined in:
- lib/linear/slope_intercept.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Function
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(slope, y_intercept) ⇒ SlopeIntercept
constructor
A new instance of SlopeIntercept.
- #to_s ⇒ Object
- #to_standard ⇒ Object
Methods inherited from Function
#direct_variation?, #execute, #to_direct_variation, #to_slope_intercept, #x_intercept
Constructor Details
#initialize(slope, y_intercept) ⇒ SlopeIntercept
Returns a new instance of SlopeIntercept
15 16 17 |
# File 'lib/linear/slope_intercept.rb', line 15 def initialize(slope, y_intercept) super end |
Class Method Details
.find(index1, array = ARGV) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/linear/slope_intercept.rb', line 4 def self.find(index1, array=ARGV) i = 0 until i == 2 raise ArgumentError, "array[#{index1 + i}] must be a number" unless (array[index1 + i].to_i.to_s == array[index1 + i] || array[index1 + i].to_f.to_s == array[index1 + i]) i += 1 end return new array[index1+0].to_f, array[index1+1].to_f end |
Instance Method Details
#to_s ⇒ Object
12 13 14 |
# File 'lib/linear/slope_intercept.rb', line 12 def to_s return super.sub "f(x)", "y" end |