Class: Airplay::Device
- Inherits:
-
Object
- Object
- Airplay::Device
- Defined in:
- lib/airplay/device.rb,
lib/airplay/device/info.rb,
lib/airplay/device/features.rb
Overview
Public: Represents an Airplay Node
Defined Under Namespace
Constant Summary collapse
- MissingAttributes =
Class.new(KeyError)
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#connection ⇒ Object
Public: Establishes a conection to the device.
-
#features ⇒ Object
Public: Access the Features of the device.
-
#info ⇒ Object
Public: Access the Info of the device.
-
#initialize(attributes = {}) ⇒ Device
constructor
A new instance of Device.
-
#ip ⇒ Object
Public: Access the ip of the device.
-
#password? ⇒ Boolean
Public: Checks if the devices has a password.
-
#refresh_connection ⇒ Object
Public: Forces the refresh of the connection.
-
#server_info ⇒ Object
Public: Access the full information of the device.
Methods included from Playable
#play, #player, #playlist, #playlists
Constructor Details
#initialize(attributes = {}) ⇒ Device
Returns a new instance of Device.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/airplay/device.rb', line 18 def initialize(attributes = {}) validate_attributes(attributes) @name = attributes[:name] @address = attributes[:address] @type = attributes[:type] @password = attributes[:password] Airplay.configuration.load end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
13 14 15 |
# File 'lib/airplay/device.rb', line 13 def address @address end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/airplay/device.rb', line 13 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
13 14 15 |
# File 'lib/airplay/device.rb', line 13 def password @password end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/airplay/device.rb', line 13 def type @type end |
Instance Method Details
#connection ⇒ Object
Public: Establishes a conection to the device
Returns the Connection
93 94 95 |
# File 'lib/airplay/device.rb', line 93 def connection @_connection ||= Airplay::Connection.new(self) end |
#features ⇒ Object
Public: Access the Features of the device
Returns the Featurs of the device
69 70 71 |
# File 'lib/airplay/device.rb', line 69 def features @_features ||= Features.new(self) end |
#info ⇒ Object
Public: Access the Info of the device
Returns the Info of the device
77 78 79 |
# File 'lib/airplay/device.rb', line 77 def info @_info ||= Info.new(self) end |
#ip ⇒ Object
Public: Access the ip of the device
Returns the memoized ip address
33 34 35 |
# File 'lib/airplay/device.rb', line 33 def ip @_ip ||= address.split(":").first end |
#password? ⇒ Boolean
Public: Checks if the devices has a password
Returns boolean for the presence of a password
51 52 53 |
# File 'lib/airplay/device.rb', line 51 def password? !!password && !password.empty? end |
#refresh_connection ⇒ Object
Public: Forces the refresh of the connection
Returns nothing
101 102 103 |
# File 'lib/airplay/device.rb', line 101 def refresh_connection @_connection = nil end |
#server_info ⇒ Object
Public: Access the full information of the device
Returns a hash with all the information
85 86 87 |
# File 'lib/airplay/device.rb', line 85 def server_info @_server_info ||= basic_info.merge(extra_info) end |