Class: Mumukit::Assistant::Message::Progressive

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/assistant/message.rb

Overview

Progressive messages depend on the number of attemps They work with exactly two or three messages:

* the first message will be displayed in the first three attemps
* the second message will be displayed in the fourth, fifth and sixth attemps
* the third message will be displayed starting at the seventh attemp

Instance Method Summary collapse

Constructor Details

#initialize(alternatives) ⇒ Progressive

Returns a new instance of Progressive.



22
23
24
25
# File 'lib/mumukit/assistant/message.rb', line 22

def initialize(alternatives)
  raise 'You need two or three alternatives' unless alternatives.size.between?(2, 3)
  @alternatives = alternatives
end

Instance Method Details

#call(attemps_count) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/mumukit/assistant/message.rb', line 27

def call(attemps_count)
  case attemps_count
    when (1..3) then @alternatives.first
    when (4..6) then @alternatives.second
    else @alternatives.last
  end
end