Class: JLDrill::Options
- Inherits:
-
Object
- Object
- JLDrill::Options
- Defined in:
- lib/jldrill/model/Quiz/Options.rb
Overview
Options for the standard quiz.
Constant Summary collapse
- RANDOM_ORDER_RE =
/^Random Order/
- PROMOTE_THRESH_RE =
/^Promotion Threshold: (.*)/
- INTRO_THRESH_RE =
/^Introduction Threshold: (.*)/
- DICTIONARY_RE =
/^Dictionary: (.*)/
- LANGUAGE_RE =
/^Language: (.*)/
- REVIEW_MEANING_RE =
/^Review Meaning/
- REVIEW_KANJI_RE =
/^Review Kanji/
- REVIEW_READING_RE =
/^Review Reading/
- AUTOLOAD_DIC_RE =
/^Autoload Dictionary/
- FORGETTING_THRESH_RE =
/^Forgetting Threshold: (.*)/
Instance Attribute Summary collapse
-
#autoloadDic ⇒ Object
Returns the value of attribute autoloadDic.
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
-
#forgettingThresh ⇒ Object
Returns the value of attribute forgettingThresh.
-
#introThresh ⇒ Object
Returns the value of attribute introThresh.
-
#language ⇒ Object
Returns the value of attribute language.
-
#promoteThresh ⇒ Object
Returns the value of attribute promoteThresh.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#randomOrder ⇒ Object
Returns the value of attribute randomOrder.
-
#reviewKanji ⇒ Object
Returns the value of attribute reviewKanji.
-
#reviewMeaning ⇒ Object
Returns the value of attribute reviewMeaning.
-
#reviewMode ⇒ Object
Returns the value of attribute reviewMode.
-
#reviewOptionsSet ⇒ Object
readonly
Returns the value of attribute reviewOptionsSet.
-
#reviewReading ⇒ Object
Returns the value of attribute reviewReading.
-
#tanaka ⇒ Object
readonly
Returns the value of attribute tanaka.
Instance Method Summary collapse
-
#allowedLevels ⇒ Object
Return an array containing the allowed levels for the drills.
-
#assign(options) ⇒ Object
Assigns all the options from one to the other, but does *keeps the same quiz*.
- #clearReviewOptions ⇒ Object
- #clone ⇒ Object
- #defaultReviewOptions ⇒ Object
- #eql?(options) ⇒ Boolean
-
#initialize(quiz) ⇒ Options
constructor
A new instance of Options.
- #modifiedButNoSaveNeeded ⇒ Object
- #parseLine(line) ⇒ Object
- #saveNeeded ⇒ Object
- #setReviewOptions(value) ⇒ Object
-
#status ⇒ Object
Return a string showing the current state of the options.
- #subscribe(subscriber) ⇒ Object
- #to_s ⇒ Object
- #unsubscribe(subscriber) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(quiz) ⇒ Options
Returns a new instance of Options.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 25 def initialize(quiz) @quiz = quiz @publisher = Context::Publisher.new(self) @randomOrder = false @promoteThresh = 2 @introThresh = 10 @reviewMode = false @dictionary = nil @language = "Japanese" @tanaka = nil @reviewOptionsSet = false @autoloadDic = false @forgettingThresh = 0.0 defaultReviewOptions end |
Instance Attribute Details
#autoloadDic ⇒ Object
Returns the value of attribute autoloadDic.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def autoloadDic @autoloadDic end |
#dictionary ⇒ Object
Returns the value of attribute dictionary.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def dictionary @dictionary end |
#forgettingThresh ⇒ Object
Returns the value of attribute forgettingThresh.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def forgettingThresh @forgettingThresh end |
#introThresh ⇒ Object
Returns the value of attribute introThresh.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def introThresh @introThresh end |
#language ⇒ Object
Returns the value of attribute language.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def language @language end |
#promoteThresh ⇒ Object
Returns the value of attribute promoteThresh.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def promoteThresh @promoteThresh end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def publisher @publisher end |
#randomOrder ⇒ Object
Returns the value of attribute randomOrder.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def randomOrder @randomOrder end |
#reviewKanji ⇒ Object
Returns the value of attribute reviewKanji.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def reviewKanji @reviewKanji end |
#reviewMeaning ⇒ Object
Returns the value of attribute reviewMeaning.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def reviewMeaning @reviewMeaning end |
#reviewMode ⇒ Object
Returns the value of attribute reviewMode.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def reviewMode @reviewMode end |
#reviewOptionsSet ⇒ Object (readonly)
Returns the value of attribute reviewOptionsSet.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def reviewOptionsSet @reviewOptionsSet end |
#reviewReading ⇒ Object
Returns the value of attribute reviewReading.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def reviewReading @reviewReading end |
#tanaka ⇒ Object (readonly)
Returns the value of attribute tanaka.
9 10 11 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 9 def tanaka @tanaka end |
Instance Method Details
#allowedLevels ⇒ Object
Return an array containing the allowed levels for the drills.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 222 def allowedLevels retVal = [] if reviewReading retVal.push(0) end if reviewKanji retVal.push(1) end if reviewMeaning retVal.push(2) end # If the user hasn't selected any levels, then # default to kanji and meaning if retVal.size == 0 retVal.push(1) retVal.push(2) end return retVal end |
#assign(options) ⇒ Object
Assigns all the options from one to the other, but does *keeps the same quiz*
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 97 def assign() self.randomOrder = .randomOrder self.promoteThresh = .promoteThresh self.introThresh = .introThresh self.dictionary = .dictionary self.language = .language setReviewOptions(.reviewOptionsSet) self.reviewMeaning = .reviewMeaning self.reviewKanji = .reviewKanji self.reviewReading = .reviewReading self.autoloadDic = .autoloadDic self.forgettingThresh = .forgettingThresh if !@quiz.nil? @quiz.recreateProblem end end |
#clearReviewOptions ⇒ Object
164 165 166 167 168 169 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 164 def clearReviewOptions @reviewMeaning = false @reviewKanji = false @reviewReading = false saveNeeded end |
#clone ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 41 def clone retVal = Options.new(@quiz) retVal.randomOrder = @randomOrder retVal.promoteThresh = @promoteThresh retVal.introThresh = @introThresh retVal.reviewMode = @reviewMode retVal.dictionary = @dictionary retVal.language = @language setReviewOptions(@reviewOptionsSet) retVal.reviewMeaning = @reviewMeaning retVal.reviewKanji = @reviewKanji retVal.reviewReading = @reviewReading retVal.autoloadDic = @autoloadDic retVal.forgettingThresh = @forgettingThresh retVal end |
#defaultReviewOptions ⇒ Object
171 172 173 174 175 176 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 171 def defaultReviewOptions @reviewMeaning = true @reviewKanji = true @reviewReading = false saveNeeded end |
#eql?(options) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 58 def eql?() .randomOrder == @randomOrder && .promoteThresh == @promoteThresh && .introThresh == @introThresh && .reviewMode == @reviewMode && .dictionary == @dictionary && .language == @language && .reviewOptionsSet == @reviewOptionsSet && .reviewMeaning == @reviewMeaning && .reviewKanji == @reviewKanji && .autoloadDic == @autoloadDic && .reviewReading == @reviewReading && .forgettingThresh == @forgettingThresh end |
#modifiedButNoSaveNeeded ⇒ Object
90 91 92 93 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 90 def modifiedButNoSaveNeeded @quiz.update unless @quiz.nil? update end |
#parseLine(line) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 242 def parseLine(line) parsed = true case line when RANDOM_ORDER_RE self.randomOrder = true when PROMOTE_THRESH_RE self.promoteThresh = $1.to_i when INTRO_THRESH_RE self.introThresh = $1.to_i when DICTIONARY_RE self.dictionary = $1 when LANGUAGE_RE self.language = $1 when REVIEW_MEANING_RE self.reviewMeaning = $1.to_i when REVIEW_KANJI_RE self.reviewKanji = $1.to_i when REVIEW_READING_RE self.reviewReading = $1.to_i when AUTOLOAD_DIC_RE self.autoloadDic = true when FORGETTING_THRESH_RE self.forgettingThresh = $1.to_f else parsed = false end parsed end |
#saveNeeded ⇒ Object
85 86 87 88 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 85 def saveNeeded @quiz.setNeedsSave(true) unless @quiz.nil? update end |
#setReviewOptions(value) ⇒ Object
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 178 def setReviewOptions(value) if (value == true) if (@reviewOptionsSet == false) clearReviewOptions end else defaultReviewOptions end @reviewOptionsSet = value end |
#status ⇒ Object
Return a string showing the current state of the options
272 273 274 275 276 277 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 272 def status retVal = "" if(@randomOrder) then retVal += "R" end retVal += "(#{@promoteThresh},#{@introThresh})" retVal end |
#subscribe(subscriber) ⇒ Object
73 74 75 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 73 def subscribe(subscriber) @publisher.subscribe(subscriber, "options") end |
#to_s ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 279 def to_s retVal = "" if(@randomOrder) retVal += "Random Order\n" end retVal += "Promotion Threshold: #{@promoteThresh}\n" retVal += "Introduction Threshold: #{@introThresh}\n" if(!@dictionary.nil?) retVal += "Dictionary: #{@dictionary}\n" end if(@language != "Japanese") retVal += "Language: #{@language}\n" end if(@reviewMeaning) retVal += "Review Meaning\n" end if(@reviewKanji) retVal += "Review Kanji\n" end if(@reviewReading) retVal += "Review Reading\n" end if(@autoloadDic) retVal += "Autoload Dictionary\n" end if(@forgettingThresh != 0) retVal += "Forgetting Threshold: #{@forgettingThresh}\n" end retVal end |
#unsubscribe(subscriber) ⇒ Object
77 78 79 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 77 def unsubscribe(subscriber) @publisher.unsubscribe(subscriber, "options") end |
#update ⇒ Object
81 82 83 |
# File 'lib/jldrill/model/Quiz/Options.rb', line 81 def update @publisher.update("options") end |