Method: Remi::BusinessRules::ParseFormula#parse

Defined in:
lib/remi/cucumber/business_rules.rb

#parse(form) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/remi/cucumber/business_rules.rb', line 38

def parse(form)
  return form unless is_formula?(form)

  form_opt = formulas[form, :match]
  raise "Unknown formula #{form}" unless form_opt[:match]

  to_replace = form.match(base_regex)[0]
  replace_with = if form_opt[:value][0] == :date_reference
    date_reference(form_opt[:value][1], form_opt[:match])
  else
    to_replace
  end

  form.gsub(to_replace, replace_with)
end