Class: OpenLogCleaner::OldHtmlDocument
- Inherits:
-
Document
- Object
- Document
- OpenLogCleaner::OldHtmlDocument
show all
- Defined in:
- lib/openlogcleaner/old_html_document.rb
Instance Attribute Summary
Attributes inherited from Document
#files, #messages, #title
Instance Method Summary
collapse
Methods inherited from Document
#initialize
Instance Method Details
#add_io(io) ⇒ Object
8
9
10
11
|
# File 'lib/openlogcleaner/old_html_document.rb', line 8
def add_io(io)
contents = Nokogiri.parse(io)
add_messages(contents)
end
|
#add_messages(contents) ⇒ 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
|
# File 'lib/openlogcleaner/old_html_document.rb', line 13
def add_messages(contents)
elems = contents.at('body').elements.to_a
line = 0
begin
until elems.empty?
nick, font, br = elems.shift, elems.shift, elems.shift
line = nick.line
if nick.name == 'font' and font.name == 'br'
elems.unshift br
next
end
raise "Oooops. #{nick.inspect} #{font.inspect} #{br.inspect}" unless (nick.name == 'b') and (font.name == 'font') and (br.nil? or br.name == 'br')
nick = nick.inner_text
color = font['color']
text = font.inner_html
messages << Say.new(nick, text, color)
end
rescue Exception => e
warn "Error on line: #{line}"
raise e
end
end
|