Class: Garb::ReportParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/garb/report_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ReportParameter

Returns a new instance of ReportParameter.



6
7
8
9
# File 'lib/garb/report_parameter.rb', line 6

def initialize(name)
  @name = name
  @elements = []
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



4
5
6
# File 'lib/garb/report_parameter.rb', line 4

def elements
  @elements
end

Instance Method Details

#<<(element) ⇒ Object



15
16
17
18
# File 'lib/garb/report_parameter.rb', line 15

def <<(element)
  (@elements += [element].flatten).compact!
  self
end

#nameObject



11
12
13
# File 'lib/garb/report_parameter.rb', line 11

def name
  @name.to_s
end

#to_paramsObject



20
21
22
23
# File 'lib/garb/report_parameter.rb', line 20

def to_params
  value = self.elements.map{|param| Garb.to_google_analytics(param)}.join(',')
  value.empty? ? {} : {self.name => value}
end