Skip to content

Instantly share code, notes, and snippets.

@jstotz
Created June 23, 2009 16:07
Show Gist options
  • Save jstotz/134639 to your computer and use it in GitHub Desktop.
Save jstotz/134639 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'pp'
# -------
cond1 = {
:type => 'transaction_field',
:params => {
:field => 'store_id',
:operator => 'equals',
:value => 9
}
}
# -------
# AND
# -------
cond2 = {
:type => 'item_field',
:params => {
:field => 'season',
:operator => 'in',
:value => ["U09", "S09"]
}
}
# AND
cond3 = {
:type => 'item_field',
:params => {
:field => 'category',
:operator => 'equals',
:value => "dresses"
}
}
# -------
# OR
# -------
cond4 = {
:type => 'item_field',
:params => {
:field => 'season',
:operator => 'in',
:value => ["S08", "F08"]
}
}
# AND
# -------
cond5sub1 = {
:type => 'item_field',
:params => {
:field => 'delivery_date',
:operator => 'between',
:value => ["1/1/08", "2/1/08"]
}
}
# OR
cond5sub2 = {
:type => 'item_field',
:params => {
:field => 'delivery_date',
:operator => 'between',
:value => ["1/1/08", "2/1/08"]
}
}
# -------
# -------
conditions = [cond1, :and, [[cond2, :and, cond3], :or, [cond4, :and, [cond5sub1, :or, cond5sub2]]]]
pp conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment