Class: Eiwa::Tag::Character
Instance Attribute Summary collapse
-
#freq ⇒ Object
readonly
Returns the value of attribute freq.
-
#grade ⇒ Object
readonly
Returns the value of attribute grade.
-
#jlpt ⇒ Object
readonly
Returns the value of attribute jlpt.
-
#kunyomi ⇒ Object
readonly
Returns the value of attribute kunyomi.
-
#meanings ⇒ Object
readonly
Returns the value of attribute meanings.
-
#onyomi ⇒ Object
readonly
Returns the value of attribute onyomi.
-
#stroke_count ⇒ Object
readonly
Returns the value of attribute stroke_count.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Any
#characters, #parent, #tag_name
Instance Method Summary collapse
Methods inherited from Any
#add_characters, #end_self, #start, #to_s
Instance Attribute Details
#freq ⇒ Object (readonly)
Returns the value of attribute freq.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def freq @freq end |
#grade ⇒ Object (readonly)
Returns the value of attribute grade.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def grade @grade end |
#jlpt ⇒ Object (readonly)
Returns the value of attribute jlpt.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def jlpt @jlpt end |
#kunyomi ⇒ Object (readonly)
Returns the value of attribute kunyomi.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def kunyomi @kunyomi end |
#meanings ⇒ Object (readonly)
Returns the value of attribute meanings.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def meanings @meanings end |
#onyomi ⇒ Object (readonly)
Returns the value of attribute onyomi.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def onyomi @onyomi end |
#stroke_count ⇒ Object (readonly)
Returns the value of attribute stroke_count.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def stroke_count @stroke_count end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'lib/eiwa/tag/character.rb', line 4 def text @text end |
Instance Method Details
#end_child(child) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eiwa/tag/character.rb', line 8 def end_child(child) if child.tag_name == "literal" @text = child.text elsif child.tag_name == "reading_meaning" @onyomi = child.rmgroup.items.select { |item| item.name == "reading" && item.attrs["r_type"] == "ja_on" }.map(&:text) @kunyomi = child.rmgroup.items.select { |item| item.name == "reading" && item.attrs["r_type"] == "ja_kun" }.map(&:text) @meanings = child.rmgroup.items.select { |item| item.name == "meaning" && (item.attrs["m_lang"].nil? || item.attrs["m_lang"] == "en") }.map(&:text) elsif child.tag_name == "misc" @grade = child["grade"]&.to_i @stroke_count = child["stroke_count"]&.to_i @freq = child["freq"]&.to_i @jlpt = child["jlpt"]&.to_i end end |