source: projects/web/branches/VINE_6_0_REL/bin/newsparser.rb @ 3129

Revision 3129, 628 bytes checked in by daisuke, 13 years ago (diff)

{errata,news,event}parser を newsparser に統合

Line 
1class NewsParser
2  attr_reader :item
3  def initialize src
4    @item = Hash.new
5    @src = src
6    @pos = 0
7    target = /\n<date>|\n<title>|\n<author>|\n<description>|\n<url>|\n<target>|\n<info>|\n<directory>|\n<update>/
8    while @pos != @src.length
9      from = @pos
10      to = @src.index target, from
11      if to == nil
12        @pos = @src.length
13        if @src[from..@src.length].match /^<([^\s]+)>(.*)/m
14          @item[$1.downcase] = $2.strip
15        end
16      else
17        @pos = to + 1
18        if @src[from..to].match /^<([^\s]+)>\n(.*)/m
19          @item[$1.downcase] = $2.strip
20        end
21      end
22    end
23  end
24end
Note: See TracBrowser for help on using the repository browser.