FormulaBuilder now recognizes qualified quantity identifiers
This commit is contained in:
parent
6785090045
commit
74c863c73a
@ -110,7 +110,12 @@ module BodyTracking
|
||||
|
||||
case left[0]
|
||||
when :bt_quantity
|
||||
if @quantity_methods[left[1]].include?(right[1])
|
||||
case
|
||||
when dot == :'::'
|
||||
token = "#{left[1]}#{dot}#{right[1]}"
|
||||
@identifiers << token
|
||||
[:bt_quantity, token]
|
||||
when @quantity_methods[left[1]].include?(right[1])
|
||||
part_index = @parts.length
|
||||
if @quantity_methods.has_key?(left[1])
|
||||
[:bt_numeric_method_call,
|
||||
|
@ -70,7 +70,16 @@ class FormulaTest < ActiveSupport::TestCase
|
||||
"quantities['Meal'][_index].created_at"},
|
||||
{type: :unindexed, content: "quantities['RM'].lastBefore(parts[0])"},
|
||||
{type: :indexed, content: "100*quantities['Energy'][_index]/parts[1][_index]"}
|
||||
]
|
||||
],
|
||||
|
||||
# Qualified quantity identifiers
|
||||
'Energy::calculated > Energy', Set['Energy::calculated', 'Energy'], [
|
||||
{type: :indexed, content: "quantities['Energy::calculated'][_index]>" \
|
||||
"quantities['Energy'][_index]"}
|
||||
],
|
||||
'"Energy::as %RM" < 100', Set['Energy::as %RM'], [
|
||||
{type: :indexed, content: "quantities['Energy::as %RM'][_index]<100"}
|
||||
],
|
||||
]
|
||||
|
||||
d_methods = ['nil?', 'abs']
|
||||
|
Reference in New Issue
Block a user