Class: JLDrill::SetOptionsContext

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

Defined Under Namespace

Classes: OptionsView

Instance Attribute Summary collapse

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) ⇒ SetOptionsContext

Returns a new instance of SetOptionsContext.



13
14
15
16
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 13

def initialize(viewBridge)
	super(viewBridge)
	@quiz = nil
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



11
12
13
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 11

def filename
  @filename
end

#quizObject (readonly)

Returns the value of attribute quiz.



11
12
13
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 11

def quiz
  @quiz
end

Instance Method Details

#createViewsObject



67
68
69
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 67

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

#destroyViewsObject



71
72
73
74
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 71

def destroyViews
    @mainView.destroy
    @mainView = nil
end

#enter(parent) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 89

def enter(parent)
	if hasQuiz?(parent)
     			super(parent)
  			@quiz = parent.quiz
  			@mainView.update(@quiz.options)
  			@mainView.run
          end
end

#exitObject



98
99
100
101
102
103
104
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 98

def exit
    if @mainView.optionsSet?
        @quiz.options.assign(@mainView.options)
              @quiz.strategy.reschedule
    end
    super
end

#getDictionaryFilenameObject



81
82
83
84
85
86
87
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 81

def getDictionaryFilename
    context = GetFilenameContext.new(@viewBridge, GetFilenameContext::OPEN)
    filename = context.enter(self)
    if !filename.nil?
        @mainView.setDictionaryFilename(filename)
    end
end

#hasQuiz?(parent) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/jldrill/contexts/SetOptionsContext.rb', line 76

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