Method: Simple2ch::Res.parse

Defined in:
lib/simple2ch/res.rb

.parse(res_num, contents, thre = nil) ⇒ Res

Datの1行から各項目を分離して、Resオブジェクトを返す

Parameters:

  • res_num (Fixnum)

    レス番号

  • contents (String)

    datのデータ1行

Returns:

  • (Res)

    新規Resオブジェクト

Raises:

  • (KakoLogException)

    過去ログ情報をパースしようとした際に発生



42
43
44
45
46
47
48
49
50
# File 'lib/simple2ch/res.rb', line 42

def self.parse(res_num, contents, thre=nil)
  unless contents.strip == KAKO_LOG_INFO
    hash = parse_dat(contents)
    hash[:thre] = thre if thre
    return self.new(res_num, hash)
  else
    raise KakoLogException
  end
end