Class: Tox::Friend

Inherits:
Object
  • Object
show all
Defined in:
lib/tox/friend.rb

Overview

Friend representation in Tox client.

Defined Under Namespace

Classes: NotConnectedError, NotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, number) ⇒ Friend

Returns a new instance of Friend.



10
11
12
13
# File 'lib/tox/friend.rb', line 10

def initialize(client, number)
  self.client = client
  self.number = number
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



8
9
10
# File 'lib/tox/friend.rb', line 8

def client
  @client
end

#numberObject

Returns the value of attribute number.



8
9
10
# File 'lib/tox/friend.rb', line 8

def number
  @number
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
25
26
# File 'lib/tox/friend.rb', line 22

def ==(other)
  return false unless self.class == other.class
  client == other.client &&
    number == other.number
end

#exist!Object Also known as: exists!

Raises:



15
16
17
18
# File 'lib/tox/friend.rb', line 15

def exist!
  raise NotFoundError, "friend #{number} not found" unless exist?
  self
end