Sha256: 88d4fce8c7f6a5860891b541f93bac922c7dad07d4dcd48973b5ca875814e746
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
module Pipio class MetadataParser def initialize(first_line) @first_line = first_line || '' end def parse { my_screen_name: my_screen_name, their_screen_name: their_screen_name, start_time: start_time, service: service } end private def service match = @first_line.match(/\(([a-z]+)\)/) if match match[1] end end def their_screen_name match = @first_line.match(/Conversation with (.+?) at/) if match match[1] end end def my_screen_name match = @first_line.match(/ on ([^()]+) /) if match match[1] end end def start_time match = @first_line.match(%r{ at ([-\d/APM: ]+) on}) if match timestamp = match[1] parse_time(timestamp) end end def parse_time(timestamp) begin Time.parse(timestamp) rescue ArgumentError TimeParser.new(nil, nil, nil).parse(timestamp) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pipio-0.0.2 | lib/pipio/metadata_parser.rb |
pipio-0.0.1 | lib/pipio/metadata_parser.rb |