Class: Msn::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/msn/contact.rb

Overview

A contact returned from Msn::Messenger#get_contacts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, display_name = nil) ⇒ Contact

:nodoc:



23
24
25
26
# File 'lib/msn/contact.rb', line 23

def initialize(email, display_name = nil)
  @email = email
  @display_name = display_name
end

Instance Attribute Details

#allowObject

Is the contact in your allow list?



11
12
13
# File 'lib/msn/contact.rb', line 11

def allow
  @allow
end

#blockObject

Is the contact in your blocked list?



14
15
16
# File 'lib/msn/contact.rb', line 14

def block
  @block
end

#display_nameObject

The contact's display name



8
9
10
# File 'lib/msn/contact.rb', line 8

def display_name
  @display_name
end

#emailObject

The contact's email



5
6
7
# File 'lib/msn/contact.rb', line 5

def email
  @email
end

#pendingObject

Is the contact in your pending list? (you stil didn't approve her)



20
21
22
# File 'lib/msn/contact.rb', line 20

def pending
  @pending
end

#reverseObject

Is the contact in your reverse list? (does she has you?)



17
18
19
# File 'lib/msn/contact.rb', line 17

def reverse
  @reverse
end

Instance Method Details

#to_sObject

:nodoc:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/msn/contact.rb', line 29

def to_s
  if display_name && display_name.length > 0
    str = "#{display_name} <#{email}>"
  else
    str = "#{email}"
  end
  if allow || reverse || pending
    str << ' ('
    pieces = []
    pieces << 'allow' if allow
    pieces << 'block' if block
    pieces << 'reverse' if reverse
    pieces << 'pending' if pending
    str << pieces.join(', ')
    str << ')'
  end
  str
end