Class: Net::TOC::Buddy
- Inherits:
-
Object
- Object
- Net::TOC::Buddy
- Includes:
- Comparable, Net::TOC
- Defined in:
- lib/aim/net_toc.rb
Constant Summary
Constants included from Net::TOC
Instance Attribute Summary collapse
-
#idle_time ⇒ Object
readonly
Returns the value of attribute idle_time.
-
#last_signon ⇒ Object
readonly
Returns the value of attribute last_signon.
-
#screen_name ⇒ Object
readonly
Returns the value of attribute screen_name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#warning_level ⇒ Object
readonly
Returns the value of attribute warning_level.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
:nodoc:.
-
#available? ⇒ Boolean
Returns
true
if status == :available. -
#away? ⇒ Boolean
Returns
true
if status == :away. -
#idle? ⇒ Boolean
Returns
true
if buddy is idle. -
#initialize(screen_name, conn) ⇒ Buddy
constructor
:nodoc:.
-
#on_status(*statuses, &callback) ⇒ Object
Pass a block to be called when status changes to any of
statuses
. -
#online? ⇒ Boolean
Returns
true
unless status == :offline. -
#raw_update(val) ⇒ Object
:nodoc:.
-
#send_im(message, auto_response = false) ⇒ Object
Sends the instant message
message
to the buddy. -
#to_s ⇒ Object
The string representation of a buddy; equivalent to Buddy#screen_name.
-
#warn(anon = :named) ⇒ Object
Warns the buddy.
Methods included from Net::TOC
#format_message, #format_screen_name, new
Constructor Details
#initialize(screen_name, conn) ⇒ Buddy
:nodoc:
250 251 252 253 254 255 256 257 258 |
# File 'lib/aim/net_toc.rb', line 250 def initialize(screen_name, conn) # :nodoc: @screen_name = screen_name @conn = conn @status = :offline @warning_level = 0 @on_status = {} @last_signon = :never @idle_time = 0 end |
Instance Attribute Details
#idle_time ⇒ Object (readonly)
Returns the value of attribute idle_time.
248 249 250 |
# File 'lib/aim/net_toc.rb', line 248 def idle_time @idle_time end |
#last_signon ⇒ Object (readonly)
Returns the value of attribute last_signon.
248 249 250 |
# File 'lib/aim/net_toc.rb', line 248 def last_signon @last_signon end |
#screen_name ⇒ Object (readonly)
Returns the value of attribute screen_name.
248 249 250 |
# File 'lib/aim/net_toc.rb', line 248 def screen_name @screen_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
248 249 250 |
# File 'lib/aim/net_toc.rb', line 248 def status @status end |
#warning_level ⇒ Object (readonly)
Returns the value of attribute warning_level.
248 249 250 |
# File 'lib/aim/net_toc.rb', line 248 def warning_level @warning_level end |
Instance Method Details
#<=>(other) ⇒ Object
:nodoc:
260 261 262 |
# File 'lib/aim/net_toc.rb', line 260 def <=>(other) # :nodoc: format_screen_name(@screen_name) <=> format_screen_name(other.screen_name) end |
#available? ⇒ Boolean
Returns true
if status == :available.
275 276 277 |
# File 'lib/aim/net_toc.rb', line 275 def available? status == :available end |
#away? ⇒ Boolean
Returns true
if status == :away.
280 281 282 |
# File 'lib/aim/net_toc.rb', line 280 def away? status == :away end |
#idle? ⇒ Boolean
Returns true
if buddy is idle.
285 286 287 |
# File 'lib/aim/net_toc.rb', line 285 def idle? @idle_time > 0 end |
#on_status(*statuses, &callback) ⇒ Object
Pass a block to be called when status changes to any of statuses
. This replaces any previously set on_status block for these statuses.
265 266 267 |
# File 'lib/aim/net_toc.rb', line 265 def on_status(*statuses, &callback) #:yields: statuses.each { | status | @on_status[status] = callback } end |
#online? ⇒ Boolean
Returns true
unless status == :offline.
270 271 272 |
# File 'lib/aim/net_toc.rb', line 270 def online? status != :offline end |
#raw_update(val) ⇒ Object
:nodoc:
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/aim/net_toc.rb', line 309 def raw_update(val) # :nodoc: # TODO: Support user types properly. name, online, warning, signon_time, idle, user_type = *val.split(":") @warning_level = warning.to_i @last_signon = Time.at(signon_time.to_i) @idle_time = idle.to_i if online == "F" update_status :offline elsif user_type[2...3] and user_type[2...3] == "U" update_status :away elsif @idle_time > 0 update_status :idle else update_status :available end end |
#send_im(message, auto_response = false) ⇒ Object
Sends the instant message message
to the buddy. If auto_response
is true, the message is marked as an automated response.
290 291 292 293 294 295 296 |
# File 'lib/aim/net_toc.rb', line 290 def send_im(, auto_response=false) puts "send_im: #{ }" # remi args = [format_screen_name(@screen_name), "\"" + () + "\""] args << "auto" if auto_response puts "@conn.toc_send_im #{args.inspect}" # remi @conn.toc_send_im *args end |
#to_s ⇒ Object
The string representation of a buddy; equivalent to Buddy#screen_name.
305 306 307 |
# File 'lib/aim/net_toc.rb', line 305 def to_s screen_name end |
#warn(anon = :named) ⇒ Object
Warns the buddy. If the argument is :anonymous, the buddy is warned anonymously. Otherwise, your name is sent with the warning. You may only warn buddies who have recently IMed you.
300 301 302 |
# File 'lib/aim/net_toc.rb', line 300 def warn(anon=:named) @conn.toc_evil(format_screen_name(@screen_name), anon == :anonymous ? "anon" : "norm") end |