Class: JLDrill::LoadTatoebaContext

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

Overview

Load the kanji, radicals and kana files one after another.

Instance Attribute Summary collapse

Attributes inherited from Context::Context

#mainView, #parent, #viewBridge

Instance Method Summary collapse

Methods inherited from Context::Context

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

Constructor Details

#initialize(viewBridge) ⇒ LoadTatoebaContext

Returns a new instance of LoadTatoebaContext.



16
17
18
19
20
21
22
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 16

def initialize(viewBridge)
	super(viewBridge)
    @sentencesFile = Config::resolveDataFile(Config::TATOEBA_SENTENCE_FILE)
          @japaneseFile = Config::resolveDataFile(Config::TATOEBA_JAPANESE_FILE)
          @linksFile = Config::resolveDataFile(Config::TATOEBA_LINKS_FILE)
          @loadFileContext = LoadFileContext.new(@viewBridge)
end

Instance Attribute Details

#japaneseFileObject

Returns the value of attribute japaneseFile.



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

def japaneseFile
  @japaneseFile
end

#sentencesFileObject

Returns the value of attribute sentencesFile.



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

def sentencesFile
  @sentencesFile
end

Instance Method Details

#createViewsObject



24
25
26
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 24

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

#destroyViewsObject



28
29
30
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 28

def destroyViews
    @mainView = nil
end

#enter(parent, tatoebaDatabase) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 74

def enter(parent, tatoebaDatabase)
    super(parent)
    @db = tatoebaDatabase
    if !@db.sentences.loaded?
        loadSentences()
    else
        loadLanguage()
    end
end

#exitLoadTatoebaContextObject



62
63
64
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 62

def exitLoadTatoebaContext
    self.exit
end

#loadChineseObject



55
56
57
58
59
60
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 55

def loadChinese
    @loadFileContext.onExit do
        exitLoadTatoebaContext
    end
    @loadFileContext.enter(self, @db.chineseIndeces, @linksFile)
end

#loadJapaneseObject



48
49
50
51
52
53
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 48

def loadJapanese
    @loadFileContext.onExit do
        exitLoadTatoebaContext
    end
    @loadFileContext.enter(self, @db.japaneseIndeces, @japaneseFile)
end

#loadLanguageObject



39
40
41
42
43
44
45
46
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 39

def loadLanguage()
    language = @parent.quiz.options.language
    if language.eql?("Chinese")
        loadChinese
    else
        loadJapanese
    end
end

#loadSentencesObject



32
33
34
35
36
37
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 32

def loadSentences()
    @loadFileContext.onExit do
        loadLanguage()
    end
    @loadFileContext.enter(self, @db.sentences, @sentencesFile)
end

#startLongEventObject



66
67
68
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 66

def startLongEvent()
    @parent.startLongEvent()
end

#stopLongEventObject



70
71
72
# File 'lib/jldrill/contexts/LoadTatoebaContext.rb', line 70

def stopLongEvent()
    @parent.stopLongEvent()
end