Class: JLDrill::ShowStatisticsContext

Inherits:
Context::Context show all
Defined in:
lib/jldrill/contexts/ShowStatisticsContext.rb

Defined Under Namespace

Classes: StatisticsView

Instance Attribute Summary

Attributes inherited from Context::Context

#mainView, #parent, #viewBridge

Instance Method Summary collapse

Methods inherited from Context::Context

#addView, #isEntered?, #onExit, #peekAtView, #setupViews

Constructor Details

#initialize(viewBridge) ⇒ ShowStatisticsContext

Returns a new instance of ShowStatisticsContext.



10
11
12
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 10

def initialize(viewBridge)
	super(viewBridge)
end

Instance Method Details

#createViewsObject



49
50
51
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 49

def createViews
    		@mainView = @viewBridge.StatisticsView.new(self)
end

#destroyViewsObject



53
54
55
56
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 53

def destroyViews
    @mainView.destroy if !@mainView.nil?
    @mainView = nil
end

#enter(parent) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 63

def enter(parent)
    if hasQuiz?(parent)
  		    super(parent)
  		    @mainView.update(parent.quiz)
  		    @parent.quiz.publisher.subscribe(self, "newProblem")
              @parent.longEventPublisher.subscribe(self, "startLongEvent")
              @parent.longEventPublisher.subscribe(self, "stopLongEvent")
  		end
end

#exitObject



73
74
75
76
77
78
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 73

def exit
    @parent.quiz.publisher.unsubscribe(self, "newProblem")
          @parent.longEventPublisher.unsubscribe(self, "startLongEvent")
          @parent.longEventPublisher.unsubscribe(self, "stopLongEvent")
    super
end

#hasQuiz?(parent) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 58

def hasQuiz?(parent)
    !parent.nil? && parent.class.public_method_defined?(:quiz) &&
        !parent.quiz.nil?
end

#newProblemUpdated(problem) ⇒ Object



80
81
82
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 80

def newProblemUpdated(problem)
    @mainView.update(@parent.quiz) unless @mainView.nil?
end

#startLongEventUpdated(source) ⇒ Object



84
85
86
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 84

def startLongEventUpdated(source)
    @mainView.showBusy(true)
end

#stopLongEventUpdated(source) ⇒ Object



88
89
90
# File 'lib/jldrill/contexts/ShowStatisticsContext.rb', line 88

def stopLongEventUpdated(source)
    @mainView.showBusy(false)
end