Sha256: bf3f16f2005e6079a0ecb651f88c79754156720eb189fe4043a667e99bec1d2b
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'Context/Context' require 'Context/Bridge' require 'Context/View' module JLDrill class ShowStatisticsContext < Context::Context def initialize(viewBridge) super(viewBridge) end class StatisticsView < Context::View attr_reader :quiz def initialize(context) super(context) @quiz = nil end # This closes the window. It's a convenience function # for the test code so that it has something to catch other # than the context closing. def close @context.exit end # Destroy the window containing the view def destroy # Please define in the concrete class end # Update the view with the statistics from the quiz def update(quiz) @quiz = quiz # Please define the rest of this method in the concrete class. # You should call super(quiz) first. end end def createViews @mainView = @viewBridge.StatisticsView.new(self) end def destroyViews @mainView.destroy if !@mainView.nil? @mainView = nil end def hasQuiz?(parent) !parent.nil? && parent.class.public_method_defined?(:quiz) && !parent.quiz.nil? end def enter(parent) if hasQuiz?(parent) super(parent) @mainView.update(parent.quiz) @parent.quiz.publisher.subscribe(self, "newProblem") end end def exit @parent.quiz.publisher.unsubscribe(self, "newProblem") super end def newProblemUpdated(problem) @mainView.update(@parent.quiz) unless @mainView.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jldrill-0.5.1.7 | lib/jldrill/contexts/ShowStatisticsContext.rb |