Class: Woody::Decorators::Challenge
- Inherits:
-
Base
- Object
- Base
- Woody::Decorators::Challenge
show all
- Defined in:
- lib/woody/decorators/challenge.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Woody::Decorators::Base
Instance Method Details
#brand_name ⇒ Object
10
11
12
|
# File 'lib/woody/decorators/challenge.rb', line 10
def brand_name
brand.name
end
|
#concept_questions ⇒ Object
14
15
16
|
# File 'lib/woody/decorators/challenge.rb', line 14
def concept_questions
questions.fetch("concept") { {} }
end
|
#draft? ⇒ Boolean
18
19
20
|
# File 'lib/woody/decorators/challenge.rb', line 18
def draft?
status == "Draft"
end
|
#ended? ⇒ Boolean
22
23
24
25
|
# File 'lib/woody/decorators/challenge.rb', line 22
def ended?
@model.status == "published" &&
DateTime.parse(@model.end_date) < DateTime.now
end
|
#essentials_questions ⇒ Object
27
28
29
|
# File 'lib/woody/decorators/challenge.rb', line 27
def essentials_questions
questions.fetch("essentials") { {} }
end
|
#exist? ⇒ Boolean
31
32
33
|
# File 'lib/woody/decorators/challenge.rb', line 31
def exist?
!@model.nil?
end
|
#public? ⇒ Boolean
51
52
53
|
# File 'lib/woody/decorators/challenge.rb', line 51
def public?
@model.type == "public"
end
|
#reward_total ⇒ Object
35
36
37
38
39
|
# File 'lib/woody/decorators/challenge.rb', line 35
def reward_total
@model.rewards.inject(0) do |total, reward|
total + (reward.quantity * reward.amount)
end
end
|
#status ⇒ Object
41
42
43
44
45
|
# File 'lib/woody/decorators/challenge.rb', line 41
def status
return "Draft" if @model.status == "draft"
return "Live" if DateTime.parse(@model.end_date) > DateTime.now
purchased_videos > 0 ? "Complete" : "Video Review"
end
|
#time_left ⇒ Object
47
48
49
|
# File 'lib/woody/decorators/challenge.rb', line 47
def time_left
Time.diff(DateTime.now, @model.end_date, "%d %H")[:diff]
end
|