Class: UnderFire::Configuration
- Inherits:
-
Object
- Object
- UnderFire::Configuration
- Includes:
- Singleton
- Defined in:
- lib/under_fire/configuration.rb
Overview
Configuration information.
Instance Attribute Summary collapse
-
#config_info ⇒ Object
readonly
Returns the value of attribute config_info.
Instance Method Summary collapse
-
#api_url ⇒ String
Gracenote API url for use in queries.
-
#authorized? ⇒ Boolean
Returns true if user has a user_id.
-
#client_id ⇒ String
Gracenote client id stored in environment variable.
-
#client_id_string ⇒ String
Part of client id before the hyphen (used by api_url).
-
#client_tag ⇒ String
Part of client id after hyphen.
-
#configured? ⇒ Boolean
Returns true if user has a client_id and user_id.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset ⇒ Object
-
#user_id ⇒ String
Gracenote user id.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 |
# File 'lib/under_fire/configuration.rb', line 10 def initialize @config_info = load_config end |
Instance Attribute Details
#config_info ⇒ Object (readonly)
Returns the value of attribute config_info.
8 9 10 |
# File 'lib/under_fire/configuration.rb', line 8 def config_info @config_info end |
Instance Method Details
#api_url ⇒ String
Gracenote API url for use in queries.
40 41 42 |
# File 'lib/under_fire/configuration.rb', line 40 def api_url "https://c#{client_id_string}.web.cddbp.net/webapi/xml/1.0/" end |
#authorized? ⇒ Boolean
Returns true if user has a user_id
46 47 48 |
# File 'lib/under_fire/configuration.rb', line 46 def user_id != nil end |
#client_id ⇒ String
Gracenote client id stored in environment variable.
16 17 18 |
# File 'lib/under_fire/configuration.rb', line 16 def client_id config_info.fetch(:client_id, nil).to_s end |
#client_id_string ⇒ String
Part of client id before the hyphen (used by api_url).
22 23 24 |
# File 'lib/under_fire/configuration.rb', line 22 def client_id_string client_id.split('-')[0] end |
#client_tag ⇒ String
Part of client id after hyphen
28 29 30 |
# File 'lib/under_fire/configuration.rb', line 28 def client_tag client_id.split('-')[1] end |
#configured? ⇒ Boolean
Returns true if user has a client_id and user_id
52 53 54 |
# File 'lib/under_fire/configuration.rb', line 52 def configured? client_id != nil && ! end |
#reset ⇒ Object
56 57 58 |
# File 'lib/under_fire/configuration.rb', line 56 def reset initialize end |
#user_id ⇒ String
Gracenote user id
34 35 36 |
# File 'lib/under_fire/configuration.rb', line 34 def user_id config_info.fetch(:user_id, nil).to_s end |