Class: ChatStew::Parsers::Adium
- Inherits:
-
Object
- Object
- ChatStew::Parsers::Adium
- Defined in:
- lib/chat_stew/parsers/adium.rb
Instance Method Summary collapse
Instance Method Details
#can_parse?(file) ⇒ Boolean
8 9 10 11 12 13 |
# File 'lib/chat_stew/parsers/adium.rb', line 8 def can_parse?(file) contents = file.read file.rewind return contents.include?('<?xml version="1.0" encoding="UTF-8" ?>') && contents.include?('<chat xmlns="http://purl.org/net/ulf/ns/0.4-02"') end |
#parse(file) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chat_stew/parsers/adium.rb', line 15 def parse(file) doc = Nokogiri.XML(file) = doc.search('chat message') account = doc.at('chat')[:account] other_account = .detect{|m| m[:sender] != account }[:sender] .map do || AdiumMessage.new([:sender], [:sender] == account ? other_account : account, [:alias], .text, DateTime.parse([:time])) end end |