Class: Barker::CandidateJoker

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_atObject (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_inObject (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

#callObject

Raises:



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_idObject



18
19
20
# File 'lib/barker/candidate_joker.rb', line 18

def candidate_id
  @candidate_question.candidate_id
end

#joker_idObject Also known as: id



13
14
15
# File 'lib/barker/candidate_joker.rb', line 13

def joker_id
  @joker.id
end