Class: YmaParser

Inherits:
Object
  • Object
show all
Defined in:
lib/yma_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ YmaParser

Returns a new instance of YmaParser.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/yma_parser.rb', line 4

def initialize(xml)
  @xml = REXML::Document.new(xml)
  @total_count = @xml.elements['//total_count'].text.to_i
  @filtered_count = @xml.elements['//filtered_count'].text.to_i
  @word_list = @xml.elements['//word_list'].map do |word|
    { :surface=>word.elements['surface'].text,
      :reading=>word.elements['reading'].text,
      :pos=>word.elements['pos'].text
    }
  end
end

Instance Attribute Details

#filtered_countObject (readonly)

Returns the value of attribute filtered_count.



3
4
5
# File 'lib/yma_parser.rb', line 3

def filtered_count
  @filtered_count
end

#total_countObject (readonly)

Returns the value of attribute total_count.



3
4
5
# File 'lib/yma_parser.rb', line 3

def total_count
  @total_count
end

#word_listObject (readonly)

Returns the value of attribute word_list.



3
4
5
# File 'lib/yma_parser.rb', line 3

def word_list
  @word_list
end

#xmlObject (readonly)

Returns the value of attribute xml.



3
4
5
# File 'lib/yma_parser.rb', line 3

def xml
  @xml
end