# -*- encoding: utf-8 -*- class NewsParser attr_reader :item def initialize src @item = Hash.new @src = src @pos = 0 target = /\n|\n|\n<author>|\n<description>|\n<url>|\n<target>|\n<info>|\n<directory>|\n<update>/ while @pos != @src.length from = @pos to = @src.index target, from if to == nil @pos = @src.length if @src[from..@src.length].match /^<([^\s]+)>(.*)/m @item[$1.downcase] = $2.strip end else @pos = to + 1 if @src[from..to].match /^<([^\s]+)>\n(.*)/m @item[$1.downcase] = $2.strip end end end end end