Class: Barker::CandidateAnswer
- Inherits:
-
Object
- Object
- Barker::CandidateAnswer
- Defined in:
- lib/barker/candidate_answer.rb
Instance Attribute Summary collapse
-
#answer ⇒ Object
Returns the value of attribute answer.
-
#candidate ⇒ Object
Returns the value of attribute candidate.
-
#reveal_answer ⇒ Object
Returns the value of attribute reveal_answer.
Instance Method Summary collapse
- #answer_id ⇒ Object (also: #id)
- #candidate_id ⇒ Object
- #correct? ⇒ Boolean
-
#initialize(candidate, answer) ⇒ CandidateAnswer
constructor
A new instance of CandidateAnswer.
- #label ⇒ Object
- #reveal ⇒ Object
- #revealed? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(candidate, answer) ⇒ CandidateAnswer
Returns a new instance of CandidateAnswer.
6 7 8 9 10 |
# File 'lib/barker/candidate_answer.rb', line 6 def initialize(candidate, answer) @candidate = candidate @answer = answer @revealed = false end |
Instance Attribute Details
#answer ⇒ Object
Returns the value of attribute answer.
4 5 6 |
# File 'lib/barker/candidate_answer.rb', line 4 def answer @answer end |
#candidate ⇒ Object
Returns the value of attribute candidate.
4 5 6 |
# File 'lib/barker/candidate_answer.rb', line 4 def candidate @candidate end |
#reveal_answer ⇒ Object
Returns the value of attribute reveal_answer.
4 5 6 |
# File 'lib/barker/candidate_answer.rb', line 4 def reveal_answer @reveal_answer end |
Instance Method Details
#answer_id ⇒ Object Also known as: id
32 33 34 |
# File 'lib/barker/candidate_answer.rb', line 32 def answer_id answer.id end |
#candidate_id ⇒ Object
37 38 39 |
# File 'lib/barker/candidate_answer.rb', line 37 def candidate_id candidate.id end |
#correct? ⇒ Boolean
28 29 30 |
# File 'lib/barker/candidate_answer.rb', line 28 def correct? answer.correct? end |
#label ⇒ Object
16 17 18 |
# File 'lib/barker/candidate_answer.rb', line 16 def label answer.label[candidate.locale] || answer.label["en"] end |
#reveal ⇒ Object
24 25 26 |
# File 'lib/barker/candidate_answer.rb', line 24 def reveal @revealed = true end |
#revealed? ⇒ Boolean
20 21 22 |
# File 'lib/barker/candidate_answer.rb', line 20 def revealed? @revealed end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/barker/candidate_answer.rb', line 12 def valid? answer.valid? end |