Class: GAEvents::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/gaevents/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, category, action, label = nil, value = nil) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
10
11
# File 'lib/gaevents/event.rb', line 5

def initialize(client, category, action, label = nil, value = nil)
	@client = client
	@category = category
	@action = action
	@label = label
	@value = value
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'lib/gaevents/event.rb', line 3

def action
  @action
end

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/gaevents/event.rb', line 3

def category
  @category
end

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/gaevents/event.rb', line 3

def client
  @client
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/gaevents/event.rb', line 3

def label
  @label
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/gaevents/event.rb', line 3

def value
  @value
end

Instance Method Details

#params(tid) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gaevents/event.rb', line 13

def params(tid)
	params = {
	"v" => 1,
	"tid" => tid,
	"cid" => @client,
	"t" => "event",
	"ec" => @category,
	"ea" => @action,
	"el" => @label,
	"ev" => @value
	}
	params.reject! { |k,v| !v }
end

#payload(tid) ⇒ Object



27
28
29
# File 'lib/gaevents/event.rb', line 27

def payload(tid)
	URI.encode_www_form params(tid)
end