Class: SkypeMac::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/rb-skypemac/group.rb

Overview

Represents Skype internal grouping of contacts; developer.skype.com/Docs/ApiDoc/GROUP_object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gidObject (readonly)

Returns the value of attribute gid.



9
10
11
# File 'lib/rb-skypemac/group.rb', line 9

def gid
  @gid
end

#gtypeObject (readonly)

Returns the value of attribute gtype.



9
10
11
# File 'lib/rb-skypemac/group.rb', line 9

def gtype
  @gtype
end

Class Method Details

.get_type(id) ⇒ Object

Gets the type of a group by id



13
14
15
16
# File 'lib/rb-skypemac/group.rb', line 13

def get_type(id)
  r = Skype.send_ :command => "get group #{id} type"
  r.sub(/.*TYPE\b/, "").strip
end

.groupsObject

Returns hash of symols (group types) => Group objects



25
26
27
28
29
30
31
32
33
34
# File 'lib/rb-skypemac/group.rb', line 25

def groups
  r = Skype.send_ :command => "search groups hardwired", :script_name => ""
  r.gsub!(/^\D+/, "")
  group_ids = r.split ", "
  groups = []
  group_ids.each do |id|
    groups <<  Group.new(id, Group.get_type(id))
  end
  groups
end

.typesObject

Returns an array of your Skype instance’s supported group types



19
20
21
22
# File 'lib/rb-skypemac/group.rb', line 19

def types
  groups = Group.groups
  groups.map { |g| g.gtype }
end

Instance Method Details

#<=>(grp) ⇒ Object



50
51
52
# File 'lib/rb-skypemac/group.rb', line 50

def <=>(grp)
  @gtype <=> grp.gtype
end

#member_user_namesObject

Returns array of skype names of users in this group



38
39
40
41
# File 'lib/rb-skypemac/group.rb', line 38

def member_user_names
  r = Skype.send_ :command => "get group #{@gid} users"
  r.sub(/^.*USERS /, "").split(", ")
end

#usersObject

Returns array of Users in this Group



44
45
46
# File 'lib/rb-skypemac/group.rb', line 44

def users
  member_user_names.map { |h| User.new h }
end