Class: JarvisbotSongfinder::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/jarvisbot_songfinder/providers/provider.rb

Overview

Abstract class for concrete providers to inherit from (Template Method Pattern)

Direct Known Subclasses

Bandrequest, SpotifyAPI, YoutubeAPI

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: JarvisbotSongfinder.configuration) ⇒ Provider

Returns a new instance of Provider.



12
13
14
15
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 12

def initialize(config: JarvisbotSongfinder.configuration)
  @config = config
  @errors = []
end

Class Attribute Details

.available_providersObject

Returns the value of attribute available_providers.



8
9
10
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 8

def available_providers
  @available_providers
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



11
12
13
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 11

def errors
  @errors
end

Instance Method Details

#artistObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 25

def artist
  raise NotImplementedError
end

#explicit?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 43

def explicit?
  raise NotImplementedError
end

#lengthObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 17

def length
  raise NotImplementedError
end

#providerObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 29

def provider
  raise NotImplementedError
end

#titleObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 21

def title
  raise NotImplementedError
end

#urlObject

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 39

def url
  raise NotImplementedError
end

#valid?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/jarvisbot_songfinder/providers/provider.rb', line 33

def valid?
  return false if @errors.any?

  available_in_region? && length_valid? && in_music_category?
end