Class: Barker::Candidate
- Inherits:
-
Object
show all
- Includes:
- Errors
- Defined in:
- lib/barker/candidate.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(object) ⇒ Candidate
Returns a new instance of Candidate.
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/barker/candidate.rb', line 8
def initialize(object)
raise HasToRespondToIdError unless object.respond_to?(:id)
raise HasToRespondToLocaleError unless object.respond_to?(:locale)
@id = object.id
@locale = object.locale.to_s
@joined_at = nil
@leaved_at = nil
@aborted_at = nil
end
|
Instance Attribute Details
#aborted_at ⇒ Object
Returns the value of attribute aborted_at.
6
7
8
|
# File 'lib/barker/candidate.rb', line 6
def aborted_at
@aborted_at
end
|
#id ⇒ Object
Returns the value of attribute id.
6
7
8
|
# File 'lib/barker/candidate.rb', line 6
def id
@id
end
|
#joined_at ⇒ Object
Returns the value of attribute joined_at.
6
7
8
|
# File 'lib/barker/candidate.rb', line 6
def joined_at
@joined_at
end
|
#leaved_at ⇒ Object
Returns the value of attribute leaved_at.
6
7
8
|
# File 'lib/barker/candidate.rb', line 6
def leaved_at
@leaved_at
end
|
#locale ⇒ Object
Returns the value of attribute locale.
6
7
8
|
# File 'lib/barker/candidate.rb', line 6
def locale
@locale
end
|
Instance Method Details
#abort ⇒ Object
27
28
29
|
# File 'lib/barker/candidate.rb', line 27
def abort
@aborted_at = Time.now
end
|
#aborted? ⇒ Boolean
39
40
41
|
# File 'lib/barker/candidate.rb', line 39
def aborted?
!!aborted_at
end
|
#candidate_id ⇒ Object
47
48
49
|
# File 'lib/barker/candidate.rb', line 47
def candidate_id
id
end
|
#join ⇒ Object
19
20
21
|
# File 'lib/barker/candidate.rb', line 19
def join
@joined_at = Time.now
end
|
#joined? ⇒ Boolean
31
32
33
|
# File 'lib/barker/candidate.rb', line 31
def joined?
!!joined_at
end
|
#jokers ⇒ Object
43
44
45
|
# File 'lib/barker/candidate.rb', line 43
def jokers
@jokers ||= []
end
|
#leave ⇒ Object
23
24
25
|
# File 'lib/barker/candidate.rb', line 23
def leave
@leaved_at = Time.now
end
|
#leaved? ⇒ Boolean
35
36
37
|
# File 'lib/barker/candidate.rb', line 35
def leaved?
!!leaved_at
end
|