class NewsParser
  attr_reader :item
  def initialize src
    @item = Hash.new
    @src = src
    @pos = 0
    target = /\n<date>|\n<title>|\n<description>|\n<url>/
    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
