class Pipio::MetadataParser
Public Class Methods
new(first_line)
click to toggle source
# File lib/pipio/metadata_parser.rb, line 3 def initialize(first_line) @first_line = first_line || '' end
Public Instance Methods
parse()
click to toggle source
# File lib/pipio/metadata_parser.rb, line 7 def parse { my_screen_name: my_screen_name, their_screen_name: their_screen_name, start_time: start_time, service: service } end
Private Instance Methods
my_screen_name()
click to toggle source
# File lib/pipio/metadata_parser.rb, line 32 def my_screen_name match = @first_line.match(/ on ([^()]+) /) if match match[1] end end
parse_time(timestamp)
click to toggle source
# File lib/pipio/metadata_parser.rb, line 47 def parse_time(timestamp) begin Time.parse(timestamp) rescue ArgumentError TimeParser.new(nil, nil, nil).parse(timestamp) end end
service()
click to toggle source
# File lib/pipio/metadata_parser.rb, line 18 def service match = @first_line.match(/\(([a-z]+)\)/) if match match[1] end end
start_time()
click to toggle source
# File lib/pipio/metadata_parser.rb, line 39 def start_time match = @first_line.match(%r{ at ([-\d/APM: ]+) on}) if match timestamp = match[1] parse_time(timestamp) end end
their_screen_name()
click to toggle source
# File lib/pipio/metadata_parser.rb, line 25 def their_screen_name match = @first_line.match(/Conversation with (.+?) at/) if match match[1] end end