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



8
9
10
11
12
# File 'lib/eiwa/tag/entry.rb', line 8

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#meaningsObject (readonly)

Returns the value of attribute meanings.



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

def meanings
  @meanings
end

#readingsObject (readonly)

Returns the value of attribute readings.



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

def readings
  @readings
end

#spellingsObject (readonly)

Returns the value of attribute spellings.



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

def spellings
  @spellings
end

Instance Method Details

#end_child(child) ⇒ Object



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

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



14
15
16
# File 'lib/eiwa/tag/entry.rb', line 14

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