I am creating a script for players to interact with a cash register, this register allows you to select specific items and place price rules and "promotion" rules on them. this is what I have for configuration so far
module RegisterRulesendmodule PriceRules STORE_ITEMS = { :apples => 150, :bananas => 350, :tissue_paper => 450, :soap => 850 # oooooooo were pricy here in hipster land. }endWhat I don't get is how to create the RegisterRules such that, you might have something like: "buy 2 apples get 4 free, limit of 12". or "Buy 3 bananas, get one apple free" I want to create the rules such that they are customizable but also in a way where the user can change them - should they choose. Is there any way to do something like this?
I am trying to model this off of real world POS systems, but this is where I get stuck.
Cash Register in ruby
● ARCHIVED · READ-ONLY
-
-
You can write methods in modules.
-
that doesn't help me at all and I know you can do that.What I want is a list of rules that can be compared against when specific items come in
-
Well the easiest way to do that is to just have the user specify those rules directly
<limit: 12><deal: 2 apple, 4 apple free><deal: 3 banana, 1 apple free>And then convert those into rules.If you want to do it in ruby syntax you could just as easily write it as a hash.