Class: Legato::ListParameter
- Inherits:
-
Object
- Object
- Legato::ListParameter
- Defined in:
- lib/legato/list_parameter.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tracking_scope ⇒ Object
readonly
Returns the value of attribute tracking_scope.
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #==(other) ⇒ Object
- #include?(element) ⇒ Boolean
-
#initialize(name, elements = [], tracking_scope = "ga") ⇒ ListParameter
constructor
A new instance of ListParameter.
- #to_params ⇒ Object
Constructor Details
#initialize(name, elements = [], tracking_scope = "ga") ⇒ ListParameter
Returns a new instance of ListParameter.
6 7 8 9 10 |
# File 'lib/legato/list_parameter.rb', line 6 def initialize(name, elements=[], tracking_scope = "ga") @name = name @elements = Array.wrap(elements) @tracking_scope = tracking_scope end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
4 5 6 |
# File 'lib/legato/list_parameter.rb', line 4 def elements @elements end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/legato/list_parameter.rb', line 4 def name @name end |
#tracking_scope ⇒ Object (readonly)
Returns the value of attribute tracking_scope.
4 5 6 |
# File 'lib/legato/list_parameter.rb', line 4 def tracking_scope @tracking_scope end |
Instance Method Details
#<<(element) ⇒ Object
16 17 18 19 |
# File 'lib/legato/list_parameter.rb', line 16 def <<(element) (@elements += Array.wrap(element)).compact! self end |
#==(other) ⇒ Object
26 27 28 |
# File 'lib/legato/list_parameter.rb', line 26 def ==(other) name == other.name && elements == other.elements end |
#include?(element) ⇒ Boolean
30 31 32 |
# File 'lib/legato/list_parameter.rb', line 30 def include?(element) @elements.include?(element) end |
#to_params ⇒ Object
21 22 23 24 |
# File 'lib/legato/list_parameter.rb', line 21 def to_params value = elements.map{|element| Legato.to_ga_string(element, tracking_scope)}.join(',') value.empty? ? {} : {name => value} end |