Class: SkypeApi::User

Inherits:
Object
  • Object
show all
Defined in:
lib/skype_api/user.rb

Direct Known Subclasses

Profile

Constant Summary collapse

COMMAND =
"USER"
NOT_IN_CONTACT =

never been in contact list.

0
DELETE_FROM_CONTACT =

deleted from contact list.

1
AUTHORISATION_PENDING =

pending authorisation.

2
ADD_TO_CONTACT =

added to contact list.

3
METHOD_NAMES =
[:fullname, :birthday, :sex, :language, :province, :city,
:phone_home, :phone_office, :phone_mobile,
:homepage, :about, :buddystatus]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "") ⇒ User

Returns a new instance of User.



18
19
20
21
22
23
# File 'lib/skype_api/user.rb', line 18

def initialize(name = "")
  @name = name
  @fullname, @birthday, @sex, @language, @province, @city = nil
  @phone_home, @phone_office, @phone_mobile = nil
  @homepage, @about, @buddystatus = nil
end

Instance Attribute Details

#aboutObject (readonly)

Returns the value of attribute about.



16
17
18
# File 'lib/skype_api/user.rb', line 16

def about
  @about
end

#birthdayObject (readonly)

Returns the value of attribute birthday.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def birthday
  @birthday
end

#buddystatusObject (readonly)

Returns the value of attribute buddystatus.



16
17
18
# File 'lib/skype_api/user.rb', line 16

def buddystatus
  @buddystatus
end

#cityObject (readonly)

Returns the value of attribute city.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def city
  @city
end

#fullnameObject (readonly)

Returns the value of attribute fullname.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def fullname
  @fullname
end

#homepageObject (readonly)

Returns the value of attribute homepage.



16
17
18
# File 'lib/skype_api/user.rb', line 16

def homepage
  @homepage
end

#languageObject (readonly)

Returns the value of attribute language.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def name
  @name
end

#phone_homeObject (readonly)

Returns the value of attribute phone_home.



15
16
17
# File 'lib/skype_api/user.rb', line 15

def phone_home
  @phone_home
end

#phone_mobileObject (readonly)

Returns the value of attribute phone_mobile.



15
16
17
# File 'lib/skype_api/user.rb', line 15

def phone_mobile
  @phone_mobile
end

#phone_officeObject (readonly)

Returns the value of attribute phone_office.



15
16
17
# File 'lib/skype_api/user.rb', line 15

def phone_office
  @phone_office
end

#provinceObject (readonly)

Returns the value of attribute province.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def province
  @province
end

#sexObject (readonly)

Returns the value of attribute sex.



14
15
16
# File 'lib/skype_api/user.rb', line 14

def sex
  @sex
end

Instance Method Details

#authorisationObject



62
63
64
# File 'lib/skype_api/user.rb', line 62

def authorisation
  "SET #{COMMAND} #{@name} BUDDYSTATUS 2"
end

#fifoObject



25
26
27
28
29
# File 'lib/skype_api/user.rb', line 25

def fifo
  self.methods.collect do |method|
    self.send method if /^get_.+$/.match(method.to_s)
  end.compact
end

#get(*items) ⇒ Object



47
48
49
50
51
# File 'lib/skype_api/user.rb', line 47

def get(*items)
  items.collect do |item|
    (self.respond_to? item) ? (self.send item) : nil
  end
end

#to_sObject



53
54
55
56
57
58
59
60
# File 'lib/skype_api/user.rb', line 53

def to_s
  text = "<name = #{name.inspect}"
  METHOD_NAMES.each do |name|
    text << ", #{name.to_s} = #{(self.send name).inspect}"
  end
  text << ">"
  text
end

#update(text) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/skype_api/user.rb', line 31

def update(text)
  destination, user_name, property, *value = text.split
  property = "@#{property.downcase}".to_sym
  value = value.join(' ')
  if query_validate(destination, user_name, property)
    self.instance_variable_set property, /^\d+$/.match(value) ? value.to_i : value
  end
  self
end