Class: Garb::Management::Goal

Inherits:
Object
  • Object
show all
Defined in:
lib/garb/management/goal.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#activeObject Also known as: active?

Returns the value of attribute active.



6
7
8
# File 'lib/garb/management/goal.rb', line 6

def active
  @active
end

#destinationObject

Returns the value of attribute destination.



6
7
8
# File 'lib/garb/management/goal.rb', line 6

def destination
  @destination
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/garb/management/goal.rb', line 6

def name
  @name
end

#numberObject

Returns the value of attribute number.



6
7
8
# File 'lib/garb/management/goal.rb', line 6

def number
  @number
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/garb/management/goal.rb', line 5

def path
  @path
end

#sessionObject

Returns the value of attribute session.



5
6
7
# File 'lib/garb/management/goal.rb', line 5

def session
  @session
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/garb/management/goal.rb', line 6

def value
  @value
end

Class Method Details

.all(session = Session, path = '/accounts/~all/webproperties/~all/profiles/~all/goals') ⇒ Object



10
11
12
13
# File 'lib/garb/management/goal.rb', line 10

def self.all(session = Session, path = '/accounts/~all/webproperties/~all/profiles/~all/goals')
  feed = Feed.new(session, path)
  feed.entries.map {|entry| new_from_entry(entry, session)}
end

.for_account(account) ⇒ Object



15
16
17
# File 'lib/garb/management/goal.rb', line 15

def self.()
  all(.session, .path + '/webproperties/~all/profiles/~all/goals')
end

.for_profile(profile) ⇒ Object



23
24
25
# File 'lib/garb/management/goal.rb', line 23

def self.for_profile(profile)
  all(profile.session, profile.path + '/goals')
end

.for_web_property(web_property) ⇒ Object



19
20
21
# File 'lib/garb/management/goal.rb', line 19

def self.for_web_property(web_property)
  all(web_property.session, web_property.path + '/profiles/~all/goals')
end

.new_from_entry(entry, session) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/garb/management/goal.rb', line 27

def self.new_from_entry(entry, session)
  goal = new
  goal.session = session
  goal.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
  goal.properties = entry[Garb.to_ga('goal')]
  goal
end

Instance Method Details

#properties=(properties) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/garb/management/goal.rb', line 35

def properties=(properties)
  self.name = properties["name"]
  self.number = properties["number"].to_i
  self.value = properties["value"].to_f
  self.active = (properties["active"] == "true")
  self.destination = Destination.new(properties[Garb.to_ga('destination')])
end