Class: Airplay::Devices

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/airplay/devices.rb

Overview

Public: Represents an array of devices

Instance Method Summary collapse

Constructor Details

#initializeDevices

Returns a new instance of Devices.



13
14
15
# File 'lib/airplay/devices.rb', line 13

def initialize
  @items = []
end

Instance Method Details

#<<(device) ⇒ Object

Public: Adds a device to the list

value - The Device

Returns nothing



56
57
58
59
# File 'lib/airplay/devices.rb', line 56

def <<(device)
  return if find_by_ip(device.ip)
  @items << device
end

#add(name, address) ⇒ Object

Public: Adds a device to the pool

name - The name of the device address - The address of the device

Returns nothing



44
45
46
47
48
# File 'lib/airplay/devices.rb', line 44

def add(name, address)
  device = Device.new(name: name, address: address)
  self << device
  device
end

#find_by_ip(ip) ⇒ Object

Public: Finds a device given an ip

ip - The ip of the device

Returns a Device object



33
34
35
# File 'lib/airplay/devices.rb', line 33

def find_by_ip(ip)
  find_by_block { |device| device if device.ip == ip }
end

#find_by_name(device_name) ⇒ Object

Public: Finds a device given a name

device_name - The name of the device

Returns a Device object



23
24
25
# File 'lib/airplay/devices.rb', line 23

def find_by_name(device_name)
  find_by_block { |device| device if device.name == device_name }
end