Class: JLDrill::AddNewVocabularyContext

Inherits:
ModifyVocabularyContext show all
Defined in:
lib/jldrill/contexts/AddNewVocabularyContext.rb

Instance Attribute Summary

Attributes inherited from Context::Context

#mainView, #parent, #viewBridge

Instance Method Summary collapse

Methods inherited from ModifyVocabularyContext

#close, #createViews, #destroyViews, #dictionaryLoaded?, #edictLoadUpdated, #enter, #exit, #loadDictionary, #newProblemUpdated, #preview, #problemModifiedUpdated, #search, #startLongEventUpdated, #stopLongEventUpdated, #update

Methods inherited from Context::Context

#addView, #createViews, #destroyViews, #enter, #exit, #isEntered?, #onExit, #peekAtView, #setupViews

Constructor Details

#initialize(viewBridge) ⇒ AddNewVocabularyContext

Returns a new instance of AddNewVocabularyContext.



8
9
10
11
# File 'lib/jldrill/contexts/AddNewVocabularyContext.rb', line 8

def initialize(viewBridge)
	super(viewBridge)
          @actionName = "Add"
end

Instance Method Details

#addVocabulary(vocab) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/jldrill/contexts/AddNewVocabularyContext.rb', line 22

def addVocabulary(vocab)
    if !@parent.nil? && !@parent.quiz.nil?
  		    item = @parent.quiz.appendVocab(vocab)
              @parent.displayItem(item)
  		    @parent.updateQuizStatus
  		end
end

#doAction(vocabulary) ⇒ Object

This is called when the action button is pressed on the view. In this case it adds the vocabulary to the quiz.



15
16
17
18
19
20
# File 'lib/jldrill/contexts/AddNewVocabularyContext.rb', line 15

def doAction(vocabulary)
    if vocabulary.valid?
        addVocabulary(vocabulary)
        @mainView.clearVocabulary
    end
end