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 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/garb/report_parameter.rb', line 20 def to_params params = self.elements.map do |elem| case elem when Hash elem.collect do |k,v| next unless k.is_a?(Operator) "#{k.target}#{URI.encode(k.operator.to_s, /[=<>]/)}#{CGI::escape(v.to_s)}" end.join(';') else elem.to_ga end end.join(',') params.empty? ? {} : {self.name => params} end |