Added QuantityInput class
This commit is contained in:
parent
cd29e15b32
commit
abd7d02b89
@ -20,7 +20,7 @@ class Formula < ActiveRecord::Base
|
|||||||
def calculate(inputs)
|
def calculate(inputs)
|
||||||
raise(InvalidInputs, 'No inputs') if inputs.empty?
|
raise(InvalidInputs, 'No inputs') if inputs.empty?
|
||||||
|
|
||||||
deps = inputs.map { |q, v| [q.name, v.transpose[0]] }.to_h
|
deps = inputs.map { |q, v| [q.name, v.transpose.first] }.to_h
|
||||||
length = deps.values.first.length
|
length = deps.values.first.length
|
||||||
|
|
||||||
raise(InvalidFormula, 'Invalid formula') unless self.valid?
|
raise(InvalidFormula, 'Invalid formula') unless self.valid?
|
||||||
@ -42,6 +42,13 @@ class Formula < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
class QuantityInput < Array
|
||||||
|
def initialize(q, *args)
|
||||||
|
super(*args)
|
||||||
|
@quantity = q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def parse
|
def parse
|
||||||
d_methods = ['abs', 'nil?']
|
d_methods = ['abs', 'nil?']
|
||||||
q_methods = Hash.new(['all', 'lastBefore'])
|
q_methods = Hash.new(['all', 'lastBefore'])
|
||||||
|
Reference in New Issue
Block a user