Class: Jabber::Presence

Inherits:
Object
  • Object
show all
Defined in:
lib/lijab/contacts.rb

Constant Summary collapse

PRETTY =
Hash.new(["", []]).update(
{ :available => ["available", [:green, :bold]],
  :away => ["away", [:magenta]],
  :chat => ["chatty", [:green]],
  :dnd => ["busy", [:red, :bold]],
  :xa => ["not available", [:red]],
  :offline => ["offline", [:blue]]
})

Instance Method Summary collapse

Instance Method Details

#pretty(colorize = false) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/lijab/contacts.rb', line 21

def pretty(colorize=false)
   sh = pretty_show()

   s, colors = PRETTY[sh]
   s = s.colored(*colors) if colorize
   message = status() && !status().empty? ? " [#{status()}]" : ""
   "#{s}#{message}"
end

#pretty_showObject



12
13
14
15
16
17
18
19
# File 'lib/lijab/contacts.rb', line 12

def pretty_show
   case type()
   when nil
      show() || :available
   when :unavailable
      :offline
   end
end