Class: Legato::Filter
- Inherits:
-
Object
- Object
- Legato::Filter
- Defined in:
- lib/legato/filter.rb
Constant Summary collapse
- OPERATORS =
{ # metrics :eql => '==', :not_eql => '!=', :gt => '>', :gte => '>=', :lt => '<', :lte => '<=', # dimensions :matches => '==', :does_not_match => '!=', :substring => '=@', :not_substring => '!@', :contains => '=~', # regex :does_not_contain => '!~' # regex # :desc => '-', # :descending => '-' }
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#join_character ⇒ Object
Returns the value of attribute join_character.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#tracking_scope ⇒ Object
Returns the value of attribute tracking_scope.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#escaped_value ⇒ Object
escape comma and semicolon in value to differentiate from those used as join characters for OR/AND.
- #google_field ⇒ Object
- #google_operator ⇒ Object
-
#initialize(field, operator, value, join_character, tracking_scope = "ga") ⇒ Filter
constructor
A new instance of Filter.
- #join_with(param) ⇒ Object
- #to_param ⇒ Object
Constructor Details
#initialize(field, operator, value, join_character, tracking_scope = "ga") ⇒ Filter
Returns a new instance of Filter.
24 25 26 27 28 29 30 |
# File 'lib/legato/filter.rb', line 24 def initialize(field, operator, value, join_character, tracking_scope = "ga") self.field = field self.operator = operator self.value = value self.join_character = join_character # if nil, will be overridden by Query#apply_filter self.tracking_scope = tracking_scope end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
3 4 5 |
# File 'lib/legato/filter.rb', line 3 def field @field end |
#join_character ⇒ Object
Returns the value of attribute join_character.
3 4 5 |
# File 'lib/legato/filter.rb', line 3 def join_character @join_character end |
#operator ⇒ Object
Returns the value of attribute operator.
3 4 5 |
# File 'lib/legato/filter.rb', line 3 def operator @operator end |
#tracking_scope ⇒ Object
Returns the value of attribute tracking_scope.
3 4 5 |
# File 'lib/legato/filter.rb', line 3 def tracking_scope @tracking_scope end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/legato/filter.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/legato/filter.rb', line 57 def ==(other) field == other.field && operator == other.operator && value == other.value && join_character == other.join_character end |
#escaped_value ⇒ Object
escape comma and semicolon in value to differentiate from those used as join characters for OR/AND
42 43 44 45 46 |
# File 'lib/legato/filter.rb', line 42 def escaped_value # backslash is escaped in strings # oauth will cgi/uri escape for us value.to_s.gsub(/([,;])/) {|c| '\\'+c} end |
#google_field ⇒ Object
32 33 34 |
# File 'lib/legato/filter.rb', line 32 def google_field Legato.to_ga_string(field, tracking_scope) end |
#google_operator ⇒ Object
36 37 38 |
# File 'lib/legato/filter.rb', line 36 def google_operator OPERATORS[operator] end |
#join_with(param) ⇒ Object
52 53 54 55 |
# File 'lib/legato/filter.rb', line 52 def join_with(param) param << join_character unless param.nil? param.nil? ? to_param : (param << to_param) end |
#to_param ⇒ Object
48 49 50 |
# File 'lib/legato/filter.rb', line 48 def to_param [google_field, google_operator, escaped_value].join end |