Class: Legato::ListParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/legato/list_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elementsObject (readonly)

Returns the value of attribute elements.



4
5
6
# File 'lib/legato/list_parameter.rb', line 4

def elements
  @elements
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/legato/list_parameter.rb', line 4

def name
  @name
end

#tracking_scopeObject (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

Returns:

  • (Boolean)


30
31
32
# File 'lib/legato/list_parameter.rb', line 30

def include?(element)
  @elements.include?(element)
end

#to_paramsObject



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