| Revision 1284,
607 bytes
checked in by daisuke, 16 years ago
(diff) |
|
Initial import
|
| Line | |
|---|
| 1 | class ErrataParser |
|---|
| 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<target>|\n<url>|\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]+)>\n(.*)/m |
|---|
| 14 | @item[$1.downcase] = $2.rstrip |
|---|
| 15 | end |
|---|
| 16 | else |
|---|
| 17 | @pos = to + 1 |
|---|
| 18 | if @src[from..to].match /^<([^\s]+)>\n(.*)/m |
|---|
| 19 | @item[$1.downcase] = $2.rstrip |
|---|
| 20 | end |
|---|
| 21 | end |
|---|
| 22 | end |
|---|
| 23 | end |
|---|
| 24 | end |
|---|
Note: See
TracBrowser
for help on using the repository browser.