Class: OpenLogCleaner::Emote

Inherits:
Message
  • Object
show all
Defined in:
lib/openlogcleaner/emote.rb

Overview

<div class=‘emote’><font color=‘#008000’>** <span class=‘name’>(3) Amayria</span> <font color=‘#008000’>steals some.</font> **</font></div>

Instance Attribute Summary

Attributes inherited from Message

#color, #content, #count, #nick

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#is_ooc?, #style

Class Method Details

.from_hash(msg) ⇒ Object



34
35
36
# File 'lib/openlogcleaner/emote.rb', line 34

def self.from_hash(msg)
  new(msg[:nick], msg[:text], msg[:color])
end

.from_html(msg) ⇒ Object



16
17
18
19
20
21
# File 'lib/openlogcleaner/emote.rb', line 16

def self.from_html(msg)
  nick = parse_nick(msg)
  color = msg.at('font')[:color]
  text  = msg.at('font font').inner_html
  new(nick, text, color)
end

.parse_nick(msg) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/openlogcleaner/emote.rb', line 23

def self.parse_nick(msg)
  if (span =  msg.at('span'))
    nick = span.inner_text.sub(/^\(\d+\)\s+/, '')
    span.inner_html = nick
    nick
  else
    msg.at('font').children.first.text =~ /\*\* (.*)$/
    $1.strip
  end
end

Instance Method Details

#cssObject



8
9
10
# File 'lib/openlogcleaner/emote.rb', line 8

def css
  is_ooc? ? 'ooc' : 'emote'
end

#idObject



12
13
14
# File 'lib/openlogcleaner/emote.rb', line 12

def id
  count
end