Sha256: 1b26df6a7f5d719728b401a643fa861387066177f4f8bda4d757040d645c28d7

Contents?: true

Size: 603 Bytes

Versions: 6

Compression:

Stored size: 603 Bytes

Contents

module AirPlayer
  class Device
    class << self
      def devices
        Airplay.devices.to_a
      rescue Airplay::Browser::NoDevicesFound
        abort 'AirPlay devices not found.'
      end

      def get(device_number = 0)
        if exist?(device_number)
          Airplay[devices.at(device_number).name]
        else
          puts "Device number #{device_number} is not found. So choose #{default.name}."
          default
        end
      end

      def exist?(device_number)
        !!devices.at(device_number)
      end

      def default
        devices.first
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
airplayer-1.1.0 lib/airplayer/device.rb
airplayer-1.0.1 lib/airplayer/device.rb
airplayer-1.0.0 lib/airplayer/device.rb
airplayer-1.0.0.pre lib/airplayer/device.rb
airplayer-0.1.0 lib/airplayer/device.rb
airplayer-0.0.9 lib/airplayer/device.rb