Class: One44::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/one44-core/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Test

Returns a new instance of Test.



7
8
9
10
11
12
# File 'lib/one44-core/test.rb', line 7

def initialize(output)
  @output = output
  @marker = Marker.new
  @results = Result.new
  @welcome = Welcome.new(@output)
end

Instance Attribute Details

#markerObject (readonly)

Returns the value of attribute marker.



5
6
7
# File 'lib/one44-core/test.rb', line 5

def marker
  @marker
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/one44-core/test.rb', line 5

def output
  @output
end

#questionsObject (readonly)

Returns the value of attribute questions.



5
6
7
# File 'lib/one44-core/test.rb', line 5

def questions
  @questions
end

Instance Method Details

#provide(answer, question = 0) ⇒ Object



20
21
22
23
# File 'lib/one44-core/test.rb', line 20

def provide(answer, question = 0)
  @results << @marker.mark(@questions[question], answer)
  @output.print @results.last
end

#resultObject



25
26
27
# File 'lib/one44-core/test.rb', line 25

def result
  @output.print @results.correct.size == @questions.size ? 'PASS' : 'FAIL'
end

#start(name, questions) ⇒ Object



14
15
16
17
18
# File 'lib/one44-core/test.rb', line 14

def start(name, questions)
  @questions = questions
  @welcome.message("Welcome to one44 - #{name}")
  ask_first_question
end