Class: X2CH::Dat

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

Class Method Summary collapse

Class Method Details

.download(url, if_modified_since = nil, range = nil) ⇒ Object



215
216
217
# File 'lib/x2ch.rb', line 215

def self.download(url, if_modified_since = nil, range = nil)
  Agent.download(url, if_modified_since, range)
end

.parse(dat) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/x2ch.rb', line 219

def self.parse(dat)
  posts = []
  dat.each_line{|l|
    m = l.match(/^(\d+)<>(.+?)<>(.*?)<>(.*?)<>(.+)<>.*$/).to_a
    if m[0]
      posts << Post.new(m[2], m[3], m[4], m[5])
    else
      m = l.match(/^(.+?)<>(.*?)<>(.*?)<>(.+)<>.*$/).to_a
      if m[0]
        posts << Post.new(m[1], m[2], m[3], m[4])
      end
    end
  }
  posts
end