lib/mona/thread.rb in mona-0.1.0 vs lib/mona/thread.rb in mona-0.2.0

- old
+ new

@@ -26,9 +26,16 @@ @res_num = args[:res_num] @last_accessed_at = Time.at(args[:last_accessed_at] || 0) @dat_size = args[:dat_size] || 0 end + def self.from_url(url) + matched = url.match %r{http://(.+)/test/read.cgi/(.+)/(.+)/} + raise "Invalid Url" unless matched + board = Mona::Board.new(matched[1], matched[2]) + new(:board => board, :id => matched[3].to_i) + end + def parse_body(body) first = body.lines.first.strip.split(/<>/) @title = first[4] if first[4] end