Class: Vidsy::Data::API::Challenge

Inherits:
Object
  • Object
show all
Defined in:
lib/vidsy/data/api/challenge.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ Challenge

Returns a new instance of Challenge.



8
9
10
# File 'lib/vidsy/data/api/challenge.rb', line 8

def initialize(id = nil)
  @id = id
end

Class Method Details

.find(id) ⇒ Object



12
13
14
# File 'lib/vidsy/data/api/challenge.rb', line 12

def self.find(id)
  new.find id
end

.openObject



16
17
18
# File 'lib/vidsy/data/api/challenge.rb', line 16

def self.open
  new.open
end

Instance Method Details

#closedObject



20
21
22
# File 'lib/vidsy/data/api/challenge.rb', line 20

def closed
  client.get "#{routes.challenges}/closed"
end

#find(id) ⇒ Object



24
25
26
# File 'lib/vidsy/data/api/challenge.rb', line 24

def find(id)
  client.get("#{routes.challenge}/#{id}").first
end

#openObject



28
29
30
# File 'lib/vidsy/data/api/challenge.rb', line 28

def open
  client.get "#{routes.challenges}/open"
end

#videosObject

Raises:

  • (ArgumentError)


32
33
34
35
# File 'lib/vidsy/data/api/challenge.rb', line 32

def videos
  raise(ArgumentError, "ID not set for Challenge") if id.nil?
  client.get "#{routes.challenge}/#{id}#{routes.videos}"
end