Class: Musicz::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/musicz/configuration.rb

Defined Under Namespace

Classes: InvalidConfiguration, NoConfigBlockGiven

Constant Summary collapse

DEFAULT_BASE_URI =
"https://musicbrainz.org/ws/2"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri: DEFAULT_BASE_URI) ⇒ Configuration

Returns a new instance of Configuration.



12
13
14
# File 'lib/musicz/configuration.rb', line 12

def initialize(base_uri: DEFAULT_BASE_URI)
  @base_uri = base_uri
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



10
11
12
# File 'lib/musicz/configuration.rb', line 10

def app_name
  @app_name
end

#base_uriObject

Returns the value of attribute base_uri.



10
11
12
# File 'lib/musicz/configuration.rb', line 10

def base_uri
  @base_uri
end

#contactObject

Returns the value of attribute contact.



10
11
12
# File 'lib/musicz/configuration.rb', line 10

def contact
  @contact
end

Class Method Details

.build_defaultObject



28
29
30
31
32
33
# File 'lib/musicz/configuration.rb', line 28

def self.build_default
  new.tap do |c|
    c.app_name = "Musicz"
    c.contact = "https://github.com/derrickp/musicz"
  end
end

Instance Method Details

#errorsObject



20
21
22
23
24
25
26
# File 'lib/musicz/configuration.rb', line 20

def errors
  [].tap do |arr|
    arr << "No base_uri" if base_uri.nil?
    arr << "No app_name" if app_name.nil?
    arr << "No contact" if contact.nil?
  end
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/musicz/configuration.rb', line 16

def valid?
  errors.empty?
end