Class: SkypeHistoryImport::Importer
- Inherits:
-
Object
- Object
- SkypeHistoryImport::Importer
- Defined in:
- lib/skype-history-import.rb
Instance Attribute Summary collapse
-
#nike_to_email_mapping ⇒ Object
Returns the value of attribute nike_to_email_mapping.
Instance Method Summary collapse
Instance Attribute Details
#nike_to_email_mapping ⇒ Object
Returns the value of attribute nike_to_email_mapping.
6 7 8 |
# File 'lib/skype-history-import.rb', line 6 def nike_to_email_mapping @nike_to_email_mapping end |
Instance Method Details
#nike_to_email_map(nick, email) ⇒ Object
8 9 10 11 |
# File 'lib/skype-history-import.rb', line 8 def nike_to_email_map(nick, email) @nike_to_email_map = Hash.new if @nike_to_email_map.nil? @nike_to_email_map[nick] = email end |
#run(text) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/skype-history-import.rb', line 13 def run(text) result = [] = Message.new while text.strip.size > 0 if text =~ /^\[(.+)\] (.+?): (.*)/ # handle tail of prev multi line message unless $` == nil or .text == nil or $`.strip == "" .text += $` end # if date is only time, then found string is boby of prev message time = DateTime.strptime($1, "%H:%M:%S") rescue nil if time .text += $& else # message start = Message.new begin .date = DateTime.strptime($1, "%d/%m/%Y %H:%M:%S") .nick = $2 .text = $3 if @nike_to_email_map.nil? == false && @nike_to_email_map.has_key?(.nick) .email = @nike_to_email_map[.nick] end rescue puts "Exception '#{$!}' on match *** #{$~} ***" raise end result.push() end end text = $' end result end |