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