Class: Linear1::Standard

Inherits:
Function show all
Defined in:
lib/linear1/standard.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?, #execute, #to_direct_variation, #x_intercept

Constructor Details

#initialize(a, b, c) ⇒ Standard

Returns a new instance of Standard.



10
11
12
13
# File 'lib/linear1/standard.rb', line 10

def initialize a, b, c
	@a, @b, @c = display_num(a), display_num(b), display_num(c)
	super @c / @b / @a, @c / @b
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



4
5
6
# File 'lib/linear1/standard.rb', line 4

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



4
5
6
# File 'lib/linear1/standard.rb', line 4

def b
  @b
end

#cObject (readonly)

Returns the value of attribute c.



4
5
6
# File 'lib/linear1/standard.rb', line 4

def c
  @c
end

Class Method Details

.find(index) ⇒ Object



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

def self.find index
	array, $equation_index = ARGV[index..(index + 2)], $equation_index = index + 3
	new array[0], array[1], array[2]
end

Instance Method Details

#add(int) ⇒ Object



27
28
29
# File 'lib/linear1/standard.rb', line 27

def add int
	new @a + int, @b + int, @c + int
end

#add!(int) ⇒ Object



22
23
24
25
26
# File 'lib/linear1/standard.rb', line 22

def add! int
	@a += int
	@b += int
	@c += int
end

#multiply(int) ⇒ Object



14
15
16
# File 'lib/linear1/standard.rb', line 14

def multiply int
	new @a * int, @b * int, @c * int
end

#multiply!(factor) ⇒ Object



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

def multiply! factor
	@a *= factor
	@b *= factor
	@c *= factor
end

#to_sObject



30
31
32
# File 'lib/linear1/standard.rb', line 30

def to_s
	"#{idx a}x + #{idx b}y = #{c}"
end

#to_slope_interceptObject Also known as: to_si



33
34
35
36
# File 'lib/linear1/standard.rb', line 33

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