Class: Doattend::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/doattend/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(e = nil, k = nil) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/doattend/base.rb', line 13

def initialize(e=nil, k=nil)
	if defined? Rails
 		conf = YAML.load_file("#{Rails.root}/config/doattend.yml")
 		self.event = conf['doattend']['event']
 		self.key = conf['doattend']['key']
 	else
 		self.event = e
 		self.key = k
 	end
	self.url = "http://doattend.com/api/events/#{self.event}/participants_list.json?api_key=#{self.key}"
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



11
12
13
# File 'lib/doattend/base.rb', line 11

def event
  @event
end

#keyObject

Returns the value of attribute key.



11
12
13
# File 'lib/doattend/base.rb', line 11

def key
  @key
end

#resultObject

Returns the value of attribute result.



11
12
13
# File 'lib/doattend/base.rb', line 11

def result
  @result
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/doattend/base.rb', line 11

def url
  @url
end

Instance Method Details

#aggregateObject

Get Total Participants.



35
36
37
# File 'lib/doattend/base.rb', line 35

def aggregate
	self.result['participants'].size
end

#fetchObject

Request DoAttend and fetch results.



26
27
28
29
30
31
32
# File 'lib/doattend/base.rb', line 26

def fetch
		begin
			self.result = JSON.parse(RestClient.get(url))
		rescue Exception => e
			raise e
	end
end

#participantObject

Use methods of Participant class.



45
46
47
# File 'lib/doattend/base.rb', line 45

def participant
	Doattend::Participant.new(self.result['participants'])
end

#ticketObject

Use methods of Ticket class.



40
41
42
# File 'lib/doattend/base.rb', line 40

def ticket
	Doattend::Ticket.new(self.result['participants'])
end