Class: GoogleApi::Ga::DataDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/google_api/ga/data/data_dsl.rb

Direct Known Subclasses

FiltersDsl, SegmentDsl

Constant Summary collapse

OPERATORS =
['==', '!=', '>', '<', '>=', '<=', '=~', '!~']
OPERATORS_METHOD =
{'%' => '=@', '**' => '!@'}

Instance Method Summary collapse

Constructor Details

#initializeDataDsl

Returns a new instance of DataDsl.



8
9
10
# File 'lib/google_api/ga/data/data_dsl.rb', line 8

def initialize
  @result = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/google_api/ga/data/data_dsl.rb', line 30

def method_missing(name)
  if name.to_s =~ /\A[a-zA-Z0-9]+\Z/
    @attribute = "ga:#{name}"
    self
  else
    super
  end
end

Instance Method Details

#&(other) ⇒ Object



39
40
41
42
# File 'lib/google_api/ga/data/data_dsl.rb', line 39

def &(other)
  @result << :and
  self
end

#build_parameterObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/google_api/ga/data/data_dsl.rb', line 49

def build_parameter
  i = @result.index{ |x| x.is_a?(Symbol) }

  if !i.nil?
    result = @result[i-2] + (@result[i] == :and ? ";" : ",") + @result[i-1]
    @result.delete_at(i)
    @result.delete_at(i-1)
    @result[i-2] = result

    build_parameter
  else
    @result.join
  end
end

#|(other) ⇒ Object



44
45
46
47
# File 'lib/google_api/ga/data/data_dsl.rb', line 44

def |(other)
  @result << :or
  self
end