Method: Hallon::Session.initialize

Defined in:
lib/hallon/session.rb

.initialize(appkey, options = {}) { ... } ⇒ Session

Initializes the Spotify session. If you need to access the instance at a later time, you can use instance.

Parameters:

  • appkey (#to_s)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :user_agent (String) — default: "Hallon"

    User-Agent to use (length < 256)

  • :settings_location (String) — default: "tmp"

    where to save settings and user-specific cache

  • :cache_location (String) — default: "") where to save cache files (`""` to disable
  • :tracefile (String) — default: nil

    path to libspotify API tracefile (nil to disable)

  • :device_id (String) — default: nil

    device ID for offline synchronization (nil to disable)

  • :proxy (String) — default: nil

    proxy URI (supports http, https, socks4, socks5)

  • :load_playlists (Bool) — default: true

    load playlists into RAM on startup

  • :compress_playlists (Bool) — default: true

    compress local copies of playlists

  • :cache_playlist_metadata (Bool) — default: true

    cache metadata for playlists locally

Yields:

Returns:

Raises:

  • (ArgumentError)

    if options[:user_agent] is more than 256 characters long

  • (Hallon::Error)

    if sp_session_create fails

See Also:



48
49
50
51
# File 'lib/hallon/session.rb', line 48

def Session.initialize(appkey, options = {}, &block)
  raise "Session has already been initialized" if defined?(@__instance__)
  @__instance__ = new(appkey, options, &block)
end