Sha256: eeb550d239bd79e1bd8631dc0da1b798049a79213df4d44a2d4e2730c3ddd967
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require 'jldrill/model/Problem' require 'jldrill/model/problems/ReadingProblem' require 'jldrill/model/problems/KanjiProblem' require 'jldrill/model/problems/MeaningProblem' module JLDrill class ProblemFactory PROBLEM_TYPES = ["ReadingProblem", "KanjiProblem", "MeaningProblem"] def ProblemFactory.parse(string) PROBLEM_TYPES.find_index(string) end def ProblemFactory.lookup(level) return PROBLEM_TYPES[level] end def ProblemFactory.create(level, item) case level when 0 problem = ReadingProblem.new(item) when 1 if item.hasKanji? problem = KanjiProblem.new(item) else problem = MeaningProblem.new(item) end when 2 problem = MeaningProblem.new(item) else problem = ReadingProblem.new(item) end problem.requestedLevel = level return problem end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jldrill-0.5.1.7 | lib/jldrill/model/problems/ProblemFactory.rb |