Class: JLDrill::DictionaryEntry
- Inherits:
-
Object
- Object
- JLDrill::DictionaryEntry
- Defined in:
- lib/jldrill/model/items/DictionaryEntry.rb
Overview
A word in the dictionary. It has a reference to a DictionaryLocation and may have a cached Meaning
Constant Summary collapse
- Headings =
[["bothKanji", "Kanji", 90], ["reading", "Reading", 130], ["toVocab.definitions", "Meaning", 230]]
Instance Attribute Summary collapse
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
-
#kanji ⇒ Object
Returns the value of attribute kanji.
-
#position ⇒ Object
Returns the value of attribute position.
-
#reading ⇒ Object
Returns the value of attribute reading.
-
#relevance ⇒ Object
Returns the value of attribute relevance.
-
#simplified ⇒ Object
Returns the value of attribute simplified.
Instance Method Summary collapse
- #bothKanji ⇒ Object
-
#initialize ⇒ DictionaryEntry
constructor
A new instance of DictionaryEntry.
- #kanjiEql?(key) ⇒ Boolean
- #kanjiStartsWith?(key) ⇒ Boolean
- #keyStartsWithKanji?(key) ⇒ Boolean
- #keyStartsWithReading?(key) ⇒ Boolean
- #readingEql?(key) ⇒ Boolean
- #readingStartsWith?(key) ⇒ Boolean
- #startsWith?(key) ⇒ Boolean
- #to_s ⇒ Object
- #toMeaning ⇒ Object
- #toVocab ⇒ Object
-
#valid? ⇒ Boolean
The DictionaryEntry is valid if there is a reading.
Constructor Details
#initialize ⇒ DictionaryEntry
Returns a new instance of DictionaryEntry.
18 19 20 21 22 23 24 25 26 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 18 def initialize @kanji = "" @simplified = "" @reading = "" @dictionary = nil @position = -1 @vocab = nil @relevance = 0 end |
Instance Attribute Details
#dictionary ⇒ Object
Returns the value of attribute dictionary.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def dictionary @dictionary end |
#kanji ⇒ Object
Returns the value of attribute kanji.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def kanji @kanji end |
#position ⇒ Object
Returns the value of attribute position.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def position @position end |
#reading ⇒ Object
Returns the value of attribute reading.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def reading @reading end |
#relevance ⇒ Object
Returns the value of attribute relevance.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def relevance @relevance end |
#simplified ⇒ Object
Returns the value of attribute simplified.
13 14 15 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 13 def simplified @simplified end |
Instance Method Details
#bothKanji ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 34 def bothKanji retVal = @kanji if !@simplified.empty? retVal += "/#{@simplified}" end return retVal end |
#kanjiEql?(key) ⇒ Boolean
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 62 def kanjiEql?(key) retVal = false if !@kanji.empty? retVal |= @kanji.eql?(key) end if !@simplified.empty? retVal |= @simplified.eql?(key) end return retVal end |
#kanjiStartsWith?(key) ⇒ Boolean
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 92 def kanjiStartsWith?(key) retVal = false if !@kanji.empty? retVal |= @kanji.start_with?(key) end if !@simplified.empty? retVal |= @simplified.start_with?(key) end return retVal end |
#keyStartsWithKanji?(key) ⇒ Boolean
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 77 def keyStartsWithKanji?(key) retVal = false if !@kanji.empty? retVal |= key.start_with?(@kanji) end if !@simplified.empty? retVal |= key.start_with?(@simplified) end return retVal end |
#keyStartsWithReading?(key) ⇒ Boolean
73 74 75 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 73 def keyStartsWithReading?(key) return key.start_with?(@reading) end |
#readingEql?(key) ⇒ Boolean
58 59 60 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 58 def readingEql?(key) return @reading.eql?(key) end |
#readingStartsWith?(key) ⇒ Boolean
88 89 90 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 88 def readingStartsWith?(key) return @reading.start_with?(key) end |
#startsWith?(key) ⇒ Boolean
103 104 105 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 103 def startsWith?(key) return readingStartsWith(key) || kanjiStartsWith(key) end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 54 def to_s return @dictionary.lines[@position] end |
#toMeaning ⇒ Object
49 50 51 52 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 49 def toMeaning @meaning = @dictionary.getMeaning(@position) return @meaning end |
#toVocab ⇒ Object
42 43 44 45 46 47 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 42 def toVocab if @vocab.nil? @vocab = @dictionary.getVocab(@position) end return @vocab end |
#valid? ⇒ Boolean
The DictionaryEntry is valid if there is a reading. There doesn’t need to be a kanji
30 31 32 |
# File 'lib/jldrill/model/items/DictionaryEntry.rb', line 30 def valid? return !@reading.empty? end |