module Spotify::CountryCode

A type for converting a country code to an int, and vice versa.

Constants

PACK_FORMAT

String#pack format used by libspotify for storing country code.

Public Class Methods

from_native(country_code, ctx) click to toggle source

Given a two-char country code as int, decodes it to a string.

@param [Integer] country_code @param ctx @return [String] country code as string

# File lib/spotify/data_converters/country_code.rb, line 25
def from_native(country_code, ctx)
  [country_code].pack(PACK_FORMAT)
end
to_native(country_code, ctx) click to toggle source

Given a two-char country code, encodes it to an integer.

@param [String, nil] country_code @param ctx @return [Integer] country code as int

# File lib/spotify/data_converters/country_code.rb, line 16
def to_native(country_code, ctx)
  country_code.unpack(PACK_FORMAT)[0]
end