Class: MixpanelMagicLamp::InstanceMethods::ExpressionBuilder
- Inherits:
-
Object
- Object
- MixpanelMagicLamp::InstanceMethods::ExpressionBuilder
- Defined in:
- lib/mixpanel_magic_lamp/expression_builder.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Instance Method Summary collapse
- #and ⇒ Object
- #contains(args = {}, union = 'and') ⇒ Object
- #does_not_contain(args = {}, union = 'and') ⇒ Object
- #does_not_equal(args = {}, union = 'and') ⇒ Object
- #equals(args = {}, union = 'and') ⇒ Object
-
#initialize(*args) ⇒ ExpressionBuilder
constructor
A new instance of ExpressionBuilder.
- #is_not_set(args = [], union = 'and') ⇒ Object
- #is_set(args = [], union = 'and') ⇒ Object
- #or ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ ExpressionBuilder
Returns a new instance of ExpressionBuilder.
17 18 19 20 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 17 def initialize(*args) @expression = '' equals(*args) if args.any? end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
15 16 17 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 15 def expression @expression end |
Instance Method Details
#and ⇒ Object
26 27 28 29 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 26 def and @expression += ' and ' if @expression.present? and not @expression =~ /(and|or)\s*$/ self end |
#contains(args = {}, union = 'and') ⇒ Object
46 47 48 49 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 46 def contains(args = {}, union = 'and') @expression += join(args, union, "\":value\" in (properties[\":name\"])") self end |
#does_not_contain(args = {}, union = 'and') ⇒ Object
51 52 53 54 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 51 def does_not_contain(args = {}, union = 'and') @expression += join(args, union, "not \":value\" in (properties[\":name\"])") self end |
#does_not_equal(args = {}, union = 'and') ⇒ Object
41 42 43 44 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 41 def does_not_equal(args = {}, union = 'and') @expression += join(args, union, "properties[\":name\"] != \":value\"") self end |
#equals(args = {}, union = 'and') ⇒ Object
36 37 38 39 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 36 def equals(args = {}, union = 'and') @expression += join(args, union, "properties[\":name\"] == \":value\"") self end |
#is_not_set(args = [], union = 'and') ⇒ Object
61 62 63 64 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 61 def is_not_set(args = [], union = 'and') @expression += join(args, union, "not defined (properties[\":name\"])") self end |
#is_set(args = [], union = 'and') ⇒ Object
56 57 58 59 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 56 def is_set(args = [], union = 'and') @expression += join(args, union, "defined (properties[\":name\"])") self end |
#or ⇒ Object
31 32 33 34 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 31 def or @expression += ' or ' if @expression.present? and not @expression =~ /(and|or)\s*$/ self end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/mixpanel_magic_lamp/expression_builder.rb', line 22 def to_s @expression end |