Class: Barker::Stage
- Inherits:
-
Object
- Object
- Barker::Stage
- Defined in:
- lib/barker/stage.rb
Instance Attribute Summary collapse
-
#candidates ⇒ Object
readonly
Returns the value of attribute candidates.
-
#guideline ⇒ Object
readonly
Returns the value of attribute guideline.
-
#quiz ⇒ Object
readonly
Returns the value of attribute quiz.
Instance Method Summary collapse
- #current_round ⇒ Object
-
#initialize(quiz, candidates, options = {}) ⇒ Stage
constructor
A new instance of Stage.
- #next_round ⇒ Object
- #next_round? ⇒ Boolean
- #round_counter ⇒ Object
- #rounds ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(quiz, candidates, options = {}) ⇒ Stage
Returns a new instance of Stage.
6 7 8 9 10 11 |
# File 'lib/barker/stage.rb', line 6 def initialize(quiz, candidates, = {}) @quiz = quiz @candidates = candidates @round_counter = -1 @guideline = [:guideline] end |
Instance Attribute Details
#candidates ⇒ Object (readonly)
Returns the value of attribute candidates.
4 5 6 |
# File 'lib/barker/stage.rb', line 4 def candidates @candidates end |
#guideline ⇒ Object (readonly)
Returns the value of attribute guideline.
4 5 6 |
# File 'lib/barker/stage.rb', line 4 def guideline @guideline end |
#quiz ⇒ Object (readonly)
Returns the value of attribute quiz.
4 5 6 |
# File 'lib/barker/stage.rb', line 4 def quiz @quiz end |
Instance Method Details
#current_round ⇒ Object
21 22 23 |
# File 'lib/barker/stage.rb', line 21 def current_round round_counter != -1 && rounds[round_counter] end |
#next_round ⇒ Object
25 26 27 |
# File 'lib/barker/stage.rb', line 25 def next_round @round_counter += 1 end |
#next_round? ⇒ Boolean
29 30 31 |
# File 'lib/barker/stage.rb', line 29 def next_round? !!rounds[round_counter + 1] end |
#round_counter ⇒ Object
33 34 35 |
# File 'lib/barker/stage.rb', line 33 def round_counter @round_counter end |
#rounds ⇒ Object
17 18 19 |
# File 'lib/barker/stage.rb', line 17 def rounds @rounds ||= quiz.questions.map { |question| Barker::Round.new(question, candidates, :guideline => guideline) } end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/barker/stage.rb', line 13 def valid? quiz.valid? && candidates.any? end |