Class: Submission
- Inherits:
-
Object
- Object
- Submission
- Defined in:
- lib/papercall/models/submission.rb
Instance Attribute Summary collapse
-
#additional_info ⇒ Object
readonly
Returns the value of attribute additional_info.
-
#cfp_additional_answers ⇒ Object
readonly
Returns the value of attribute cfp_additional_answers.
-
#co_presenter_profiles ⇒ Object
readonly
Returns the value of attribute co_presenter_profiles.
-
#confirmed ⇒ Object
readonly
Returns the value of attribute confirmed.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#feedback ⇒ Object
Returns the value of attribute feedback.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#presenter_profile ⇒ Object
readonly
Returns the value of attribute presenter_profile.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#ratings ⇒ Object
Returns the value of attribute ratings.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#talk ⇒ Object
readonly
Returns the value of attribute talk.
-
#trust ⇒ Object
readonly
Returns the value of attribute trust.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #accepted? ⇒ Boolean
- #confirmed? ⇒ Boolean
- #enough_reviews? ⇒ Boolean
- #highly_rated? ⇒ Boolean
-
#initialize(json_hash) ⇒ Submission
constructor
A new instance of Submission.
- #low_rated? ⇒ Boolean
- #maybe? ⇒ Boolean
- #no_feedback? ⇒ Boolean
- #no_reviews? ⇒ Boolean
- #rejected? ⇒ Boolean
- #to_json ⇒ Object
- #to_s ⇒ Object
- #too_many_reviews? ⇒ Boolean
- #waitlisted? ⇒ Boolean
Constructor Details
#initialize(json_hash) ⇒ Submission
Returns a new instance of Submission.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/papercall/models/submission.rb', line 9 def initialize(json_hash) @id = json_hash[:id] @state = json_hash[:state] @confirmed = json_hash[:confirmed] @created_at = Time.parse(json_hash[:created_at]) @updated_at = Time.parse(json_hash[:updated_at]) @additional_info = json_hash[:additional_info] @rating = json_hash[:rating] @trust = json_hash[:trust] @tags = json_hash[:tags] @co_presenter_profiles = json_hash[:co_presenter_profiles] @presenter_profile = PresenterProfile.new(json_hash[:profile]) @talk = Talk.new(json_hash[:talk]) @cfp_additional_answers = json_hash[:cfp_additional_question_answers] @ratings = [] @feedback = [] end |
Instance Attribute Details
#additional_info ⇒ Object (readonly)
Returns the value of attribute additional_info.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def additional_info @additional_info end |
#cfp_additional_answers ⇒ Object (readonly)
Returns the value of attribute cfp_additional_answers.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def cfp_additional_answers @cfp_additional_answers end |
#co_presenter_profiles ⇒ Object (readonly)
Returns the value of attribute co_presenter_profiles.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def co_presenter_profiles @co_presenter_profiles end |
#confirmed ⇒ Object (readonly)
Returns the value of attribute confirmed.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def confirmed @confirmed end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def created_at @created_at end |
#feedback ⇒ Object
Returns the value of attribute feedback.
7 8 9 |
# File 'lib/papercall/models/submission.rb', line 7 def feedback @feedback end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def id @id end |
#presenter_profile ⇒ Object (readonly)
Returns the value of attribute presenter_profile.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def presenter_profile @presenter_profile end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def @rating end |
#ratings ⇒ Object
Returns the value of attribute ratings.
7 8 9 |
# File 'lib/papercall/models/submission.rb', line 7 def @ratings end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def state @state end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def @tags end |
#talk ⇒ Object (readonly)
Returns the value of attribute talk.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def talk @talk end |
#trust ⇒ Object (readonly)
Returns the value of attribute trust.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def trust @trust end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/papercall/models/submission.rb', line 5 def updated_at @updated_at end |
Instance Method Details
#accepted? ⇒ Boolean
51 52 53 |
# File 'lib/papercall/models/submission.rb', line 51 def accepted? @state == 'accepted' end |
#confirmed? ⇒ Boolean
63 64 65 |
# File 'lib/papercall/models/submission.rb', line 63 def confirmed? accepted? && @confirmed == true end |
#enough_reviews? ⇒ Boolean
31 32 33 |
# File 'lib/papercall/models/submission.rb', line 31 def enough_reviews? @ratings.size >= 3 end |
#highly_rated? ⇒ Boolean
39 40 41 |
# File 'lib/papercall/models/submission.rb', line 39 def highly_rated? @rating >= 75 && enough_reviews? end |
#low_rated? ⇒ Boolean
43 44 45 |
# File 'lib/papercall/models/submission.rb', line 43 def low_rated? @rating <= 25 && enough_reviews? end |
#maybe? ⇒ Boolean
47 48 49 |
# File 'lib/papercall/models/submission.rb', line 47 def maybe? !accepted? && !rejected? && enough_reviews? end |
#no_feedback? ⇒ Boolean
67 68 69 |
# File 'lib/papercall/models/submission.rb', line 67 def no_feedback? @feedback.empty? end |
#no_reviews? ⇒ Boolean
27 28 29 |
# File 'lib/papercall/models/submission.rb', line 27 def no_reviews? @ratings.empty? end |
#rejected? ⇒ Boolean
55 56 57 |
# File 'lib/papercall/models/submission.rb', line 55 def rejected? @state == 'rejected' end |
#to_json ⇒ Object
75 76 77 |
# File 'lib/papercall/models/submission.rb', line 75 def to_json this.to_h.to_json end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/papercall/models/submission.rb', line 71 def to_s puts "Submission: #{@id}, #{@talk.title}, #{@presenter_profile.name}. Number of reviews: #{@ratings.size}. Number of feedback: #{@feedback.size}" end |
#too_many_reviews? ⇒ Boolean
35 36 37 |
# File 'lib/papercall/models/submission.rb', line 35 def too_many_reviews? @ratings.size >= 4 end |
#waitlisted? ⇒ Boolean
59 60 61 |
# File 'lib/papercall/models/submission.rb', line 59 def waitlisted? @state == 'waitlist' end |