Sha256: 27da68b9a35bc1f56e3f3b45065302c404a18e796c2b3ebb79acee60b605e22f
Contents?: true
Size: 1022 Bytes
Versions: 8
Compression:
Stored size: 1022 Bytes
Contents
class SymbolOperator def initialize(field, operator) @field, @operator = field, operator end unless method_defined?(:initialize) def to_google_analytics operators = { :eql => '==', :not_eql => '!=', :gt => '>', :gte => '>=', :lt => '<', :lte => '<=', :matches => '==', :does_not_match => '!=', :contains => '=~', :does_not_contain => '!~', :substring => '=@', :not_substring => '!@', :desc => '-', :descending => '-' } target = Garb.to_google_analytics(@field) operator = operators[@operator] [:desc, :descending].include?(@operator) ? "#{operator}#{target}" : "#{target}#{operator}" end end class Symbol [:eql, :not_eql, :gt, :gte, :lt, :lte, :desc, :descending, :matches, :does_not_match, :contains, :does_not_contain, :substring, :not_substring].each do |operator| define_method(operator) do SymbolOperator.new(self, operator) end unless method_defined?(operator) end end
Version data entries
8 entries across 8 versions & 4 rubygems