Class: Barker::CandidateJoker
- Inherits:
-
Object
- Object
- Barker::CandidateJoker
- Includes:
- Errors
- Defined in:
- lib/barker/candidate_joker.rb
Constant Summary
Constants included from Errors
Errors::AlreadyAnsweredError, Errors::AlreadyStartedError, Errors::AnswerNotFoundError, Errors::BarkerError, Errors::FileNotExistError, Errors::HasToRespondToIdError, Errors::HasToRespondToLocaleError, Errors::JokerAlreadyUsedError, Errors::NoCurrentStageError, Errors::NotStartedError, Errors::RecordNotFound, Errors::UnknownJokerError
Instance Attribute Summary collapse
-
#used_at ⇒ Object
readonly
Returns the value of attribute used_at.
-
#used_in ⇒ Object
readonly
Returns the value of attribute used_in.
Instance Method Summary collapse
- #call ⇒ Object
- #candidate_id ⇒ Object
-
#initialize(candidate_question, joker) ⇒ CandidateJoker
constructor
A new instance of CandidateJoker.
- #joker_id ⇒ Object (also: #id)
Constructor Details
#initialize(candidate_question, joker) ⇒ CandidateJoker
Returns a new instance of CandidateJoker.
8 9 10 11 |
# File 'lib/barker/candidate_joker.rb', line 8 def initialize(candidate_question, joker) @candidate_question = candidate_question @joker = joker end |
Instance Attribute Details
#used_at ⇒ Object (readonly)
Returns the value of attribute used_at.
6 7 8 |
# File 'lib/barker/candidate_joker.rb', line 6 def used_at @used_at end |
#used_in ⇒ Object (readonly)
Returns the value of attribute used_in.
6 7 8 |
# File 'lib/barker/candidate_joker.rb', line 6 def used_in @used_in end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 |
# File 'lib/barker/candidate_joker.rb', line 22 def call raise UnknownJokerError unless @joker @used_at = Time.now @used_in = @candidate_question @joker.call(@used_in) end |
#candidate_id ⇒ Object
18 19 20 |
# File 'lib/barker/candidate_joker.rb', line 18 def candidate_id @candidate_question.candidate_id end |
#joker_id ⇒ Object Also known as: id
13 14 15 |
# File 'lib/barker/candidate_joker.rb', line 13 def joker_id @joker.id end |