Class: Eiwa::Tag::Entry

Inherits:
Any
  • Object
show all
Defined in:
lib/eiwa/tag/entry.rb

Instance Attribute Summary collapse

Attributes inherited from Any

#characters, #parent, #tag_name

Instance Method Summary collapse

Methods inherited from Any

#add_characters, #end_self, #start, #to_s

Constructor Details

#initializeEntry

Returns a new instance of Entry.



6
7
8
9
10
# File 'lib/eiwa/tag/entry.rb', line 6

def initialize
  @spellings = []
  @readings = []
  @meanings = []
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/eiwa/tag/entry.rb', line 4

def id
  @id
end

#meaningsObject (readonly)

Returns the value of attribute meanings.



4
5
6
# File 'lib/eiwa/tag/entry.rb', line 4

def meanings
  @meanings
end

#readingsObject (readonly)

Returns the value of attribute readings.



4
5
6
# File 'lib/eiwa/tag/entry.rb', line 4

def readings
  @readings
end

#spellingsObject (readonly)

Returns the value of attribute spellings.



4
5
6
# File 'lib/eiwa/tag/entry.rb', line 4

def spellings
  @spellings
end

Instance Method Details

#end_child(child) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/eiwa/tag/entry.rb', line 16

def end_child(child)
  case child.tag_name
  when "ent_seq"
    @id = child.characters.to_i
  when "k_ele"
    @spellings << child
  when "r_ele"
    @readings << child
  when "sense"
    child.trickle_down(@meanings.last) unless @meanings.last.nil?
    @meanings << child
  end
end

#textObject



12
13
14
# File 'lib/eiwa/tag/entry.rb', line 12

def text
  (@spellings + @readings).first.text
end