Class: Doattend::Base
- Inherits:
-
Object
- Object
- Doattend::Base
- Defined in:
- lib/doattend/base.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Returns the value of attribute event.
-
#key ⇒ Object
Returns the value of attribute key.
-
#result ⇒ Object
Returns the value of attribute result.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#aggregate ⇒ Object
Get Total Participants.
-
#fetch ⇒ Object
Request DoAttend and fetch results.
-
#initialize(e = nil, k = nil) ⇒ Base
constructor
A new instance of Base.
-
#participant ⇒ Object
Use methods of Participant class.
-
#ticket ⇒ Object
Use methods of Ticket class.
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
#event ⇒ Object
Returns the value of attribute event.
11 12 13 |
# File 'lib/doattend/base.rb', line 11 def event @event end |
#key ⇒ Object
Returns the value of attribute key.
11 12 13 |
# File 'lib/doattend/base.rb', line 11 def key @key end |
#result ⇒ Object
Returns the value of attribute result.
11 12 13 |
# File 'lib/doattend/base.rb', line 11 def result @result end |
#url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/doattend/base.rb', line 11 def url @url end |
Instance Method Details
#aggregate ⇒ Object
Get Total Participants.
35 36 37 |
# File 'lib/doattend/base.rb', line 35 def aggregate self.result['participants'].size end |
#fetch ⇒ Object
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 |
#participant ⇒ Object
Use methods of Participant class.
45 46 47 |
# File 'lib/doattend/base.rb', line 45 def participant Doattend::Participant.new(self.result['participants']) end |