Class: JLDrill::Tanaka::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/model/Tanaka.rb

Overview

Represents one of the words stored in the Tanaka library

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Word

Returns a new instance of Word.



11
12
13
# File 'lib/jldrill/model/Tanaka.rb', line 11

def initialize(contents)
    @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



9
10
11
# File 'lib/jldrill/model/Tanaka.rb', line 9

def contents
  @contents
end

Class Method Details

.create(kanji, reading) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/jldrill/model/Tanaka.rb', line 15

def Word.create(kanji, reading)
    contents = kanji
    if !reading.nil?
        contents += "(#{reading})"
    end
    return Word.new(contents)
end

Instance Method Details

#eql?(word) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/jldrill/model/Tanaka.rb', line 27

def eql?(word)
    return @contents.eql?(word.contents)
end

#hashObject



31
32
33
# File 'lib/jldrill/model/Tanaka.rb', line 31

def hash
    @contents.hash
end

#to_sObject



23
24
25
# File 'lib/jldrill/model/Tanaka.rb', line 23

def to_s
    @contents
end