Skip to content

Instantly share code, notes, and snippets.

@leehambley
Created August 11, 2009 12:29
Show Gist options
  • Save leehambley/165784 to your computer and use it in GitHub Desktop.
Save leehambley/165784 to your computer and use it in GitHub Desktop.
# £1.54 discount on 3 or more Strawberries
grammar PricingRules
rule discount
amount / item
end
rule item
"Fruit Tea" / "Coffee" / "Strawberries"
end
rule amount
# Must match: http://www.rubular.com/regexes/9480
("free" / [\d+\.\d{2}|free|\d\dp]) {
def eval
(text_value == 'free' ? 0.00 : text_value.to_i)
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment