Sha256: 4cd8eaa8de9db8326ac84f0ad41b4c9ab98958e0baf8385f47d6407de626cc48
Contents?: true
Size: 681 Bytes
Versions: 1
Compression:
Stored size: 681 Bytes
Contents
# -*- coding: utf-8 -*- require 'time' class Mona::Response attr_accessor :name, :trip, :written_at, :body def initialize(options) options.each do |key, value| self.send("#{key}=", value) end end class << self def parse_line(line) name, _, time_str, body, _ = line.to_s.split(/<>/) name, trip = parse_name(name) time = Time.parse(time_str + " +09:00") body = body.strip.split(' <br> ').join("\n") Mona::Response.new(name: name, trip: trip, written_at: time, body: body) end def parse_name(name) name, trip = name.split(/ <\/b>/) trip = trip.match(/\w+/)[0] if trip [name, trip] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mona-0.4.0 | lib/mona/response.rb |