Class: Fetion::BuddyList
- Inherits:
-
Object
- Object
- Fetion::BuddyList
- Defined in:
- lib/rfetion/buddy_list.rb
Instance Attribute Summary collapse
-
#bid ⇒ Object
readonly
Returns the value of attribute bid.
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_contact(contact) ⇒ Object
-
#initialize(bid, name) ⇒ BuddyList
constructor
A new instance of BuddyList.
- #online_contacts_count ⇒ Object
- #to_json(*args) ⇒ Object
- #total_contacts_count ⇒ Object
Constructor Details
#initialize(bid, name) ⇒ BuddyList
Returns a new instance of BuddyList.
5 6 7 8 9 |
# File 'lib/rfetion/buddy_list.rb', line 5 def initialize(bid, name) @bid = bid @name = name @contacts = [] end |
Instance Attribute Details
#bid ⇒ Object (readonly)
Returns the value of attribute bid.
3 4 5 |
# File 'lib/rfetion/buddy_list.rb', line 3 def bid @bid end |
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
3 4 5 |
# File 'lib/rfetion/buddy_list.rb', line 3 def contacts @contacts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rfetion/buddy_list.rb', line 3 def name @name end |
Class Method Details
.parse(buddy_list) ⇒ Object
15 16 17 |
# File 'lib/rfetion/buddy_list.rb', line 15 def self.parse(buddy_list) self.new(buddy_list['id'], buddy_list['name']) end |
Instance Method Details
#add_contact(contact) ⇒ Object
19 20 21 |
# File 'lib/rfetion/buddy_list.rb', line 19 def add_contact(contact) @contacts << contact end |
#online_contacts_count ⇒ Object
23 24 25 |
# File 'lib/rfetion/buddy_list.rb', line 23 def online_contacts_count @contacts.select {|contact| contact.status == "400"}.size end |
#to_json(*args) ⇒ Object
11 12 13 |
# File 'lib/rfetion/buddy_list.rb', line 11 def to_json(*args) {:bid => @bid, :name => @name, :contacts => @contacts, :total_contacts => total_contacts_count, :online_contacts => online_contacts_count}.to_json(*args) end |
#total_contacts_count ⇒ Object
27 28 29 |
# File 'lib/rfetion/buddy_list.rb', line 27 def total_contacts_count @contacts.size end |