Class: Garb::ReportParameter
- Inherits:
-
Object
- Object
- Garb::ReportParameter
- Defined in:
- lib/garb/report_parameter.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
- #<<(element) ⇒ Object
-
#initialize(name) ⇒ ReportParameter
constructor
A new instance of ReportParameter.
- #name ⇒ Object
- #to_params ⇒ Object
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
#elements ⇒ Object (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 |
#name ⇒ Object
11 12 13 |
# File 'lib/garb/report_parameter.rb', line 11 def name @name.to_s end |
#to_params ⇒ Object
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 |