Class: Wes::Data::API::Challenge
- Inherits:
-
Object
- Object
- Wes::Data::API::Challenge
- Defined in:
- lib/wes/data/api/challenge.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
- #closed ⇒ Object
- #drafts ⇒ Object
-
#initialize(attributes) ⇒ Challenge
constructor
A new instance of Challenge.
- #open ⇒ Object
- #videos ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Challenge
Returns a new instance of Challenge.
10 11 12 |
# File 'lib/wes/data/api/challenge.rb', line 10 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/wes/data/api/challenge.rb', line 8 def attributes @attributes end |
Class Method Details
.client ⇒ Object
15 16 17 |
# File 'lib/wes/data/api/challenge.rb', line 15 def client Client.new end |
.configuration ⇒ Object
19 20 21 |
# File 'lib/wes/data/api/challenge.rb', line 19 def configuration Configuration end |
.find(id) ⇒ Object
23 24 25 26 |
# File 'lib/wes/data/api/challenge.rb', line 23 def find(id) attributes = client.get("#{routes.challenge}/#{id}").first new(attributes) end |
.routes ⇒ Object
28 29 30 |
# File 'lib/wes/data/api/challenge.rb', line 28 def routes configuration.routes end |
Instance Method Details
#all ⇒ Object
33 34 35 |
# File 'lib/wes/data/api/challenge.rb', line 33 def all client.get routes.challenges end |
#closed ⇒ Object
37 38 39 |
# File 'lib/wes/data/api/challenge.rb', line 37 def closed client.get "#{routes.challenges}/closed" end |
#drafts ⇒ Object
41 42 43 |
# File 'lib/wes/data/api/challenge.rb', line 41 def drafts client.get "#{routes.challenges}/drafts" end |
#open ⇒ Object
45 46 47 |
# File 'lib/wes/data/api/challenge.rb', line 45 def open client.get "#{routes.challenges}/open" end |
#videos ⇒ Object
49 50 51 52 |
# File 'lib/wes/data/api/challenge.rb', line 49 def videos raise(ArgumentError, "ID not set for Challenge") if id.nil? client.get "#{routes.challenge}/#{id}#{routes.videos}" end |