Module: Spotify::Util
- Defined in:
- lib/spotify/util.rb
Overview
Public utility helper methods.
Class Method Summary collapse
-
.enum_value!(symbol, type) ⇒ Integer
Retrieves the associated value of an enum from a given symbol, raising an error if it does not exist.
-
.linux? ⇒ Boolean
True if on Linux.
-
.platform ⇒ Symbol
Platform as either :mac, :windows, or :linux.
Class Method Details
.enum_value!(symbol, type) ⇒ Integer
Retrieves the associated value of an enum from a given symbol, raising an error if it does not exist.
19 20 21 |
# File 'lib/spotify/util.rb', line 19 def enum_value!(symbol, type) Spotify::API.enum_value(symbol) or raise ArgumentError, "invalid #{type}: #{symbol.inspect}" end |
.linux? ⇒ Boolean
Returns true if on Linux.
26 27 28 |
# File 'lib/spotify/util.rb', line 26 def linux? platform == :linux end |
.platform ⇒ Symbol
Returns platform as either :mac, :windows, or :linux.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/spotify/util.rb', line 32 def platform case FFI::Platform::OS when /darwin/ then :mac when /linux/ then :linux when /windows/ then :windows else $stderr.puts "[WARN] You are running the Spotify gem on an unknown platform. (#{__FILE__}:#{__LINE__})" $stderr.puts "[WARN] Platform: #{FFI::Platform::OS}" :unknown end end |