Sha256: 47fdb11be1ff2c64342b039d6466c164d554747837fdaac7915640c8b2ea3cb6
Contents?: true
Size: 654 Bytes
Versions: 1
Compression:
Stored size: 654 Bytes
Contents
# -*- coding: utf-8 -*- 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) 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.3.0 | lib/mona/response.rb |