Class: Linear::System

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

Instance Method Summary collapse

Constructor Details

#initialize(equation1, equation2) ⇒ System

Returns a new instance of System



14
15
16
# File 'lib/linear/system.rb', line 14

def initialize equation1, equation2
  @e1, @e2 = equation1, equation2
end

Instance Method Details

#<<(equation) ⇒ Object Also known as: push

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/linear/system.rb', line 6

def <<(equation)
  raise ArgumentError unless equation.kind_of? Function
  @equations << equation
end

#[](index) ⇒ Object



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

def [](index)
  @equations[index]
end

#each(&block) ⇒ Object



11
12
13
# File 'lib/linear/system.rb', line 11

def each(&block)
  @system.each {yield}
end

#execute(x) ⇒ Object



17
18
19
20
21
# File 'lib/linear/system.rb', line 17

def execute x
  final = Array.new
  @equations.each {|equation| final << equation.execute(x)}
  return final
end