Class: Belir::Equation

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

Overview

Represents an Equation with one output and multiple input values

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, *inputs, &block) ⇒ Equation



9
10
11
12
13
# File 'lib/belir.rb', line 9

def initialize(output, *inputs, &block)
  @output = output
  @inputs = inputs
  @lambda = block
end

Instance Attribute Details

#inputsObject (readonly)

Returns the value of attribute inputs.



7
8
9
# File 'lib/belir.rb', line 7

def inputs
  @inputs
end

#outputObject (readonly)

Returns the value of attribute output.



6
7
8
# File 'lib/belir.rb', line 6

def output
  @output
end

Instance Method Details

#calculate(*inputs) ⇒ Object



15
16
17
18
# File 'lib/belir.rb', line 15

def calculate(*inputs)
  # Note the splat (*inputs) to convert [2] => 2
  @lambda.call(*inputs)
end