Class: Faussaire::Music
- Inherits:
-
Object
- Object
- Faussaire::Music
- Defined in:
- lib/faussaire/music.rb
Constant Summary collapse
- DATA_PATH =
File.('../../../locale/fr.yml', __FILE__)
Class Method Summary collapse
-
.fetch(key) ⇒ Object?
Fetches and samples data based on the provided key.
-
.house ⇒ String
Produces a random house song.
-
.rap ⇒ String
Produces a random French rap song.
-
.variete ⇒ String
Produces a random French variété song.
Class Method Details
.fetch(key) ⇒ Object?
Fetches and samples data based on the provided key. If the fetched data is an array, it samples a single item, otherwise returns the data directly.
14 15 16 17 18 |
# File 'lib/faussaire/music.rb', line 14 def self.fetch(key) data = YAML.load_file(DATA_PATH) result = data.dig(*key.split('.')) result.is_a?(Array) ? result.sample : result end |
.house ⇒ String
Produces a random house song.
28 29 30 |
# File 'lib/faussaire/music.rb', line 28 def self.house fetch('fr.faussaire.music.house') end |
.rap ⇒ String
Produces a random French rap song.
40 41 42 |
# File 'lib/faussaire/music.rb', line 40 def self.rap fetch('fr.faussaire.music.rap') end |
.variete ⇒ String
Produces a random French variété song.
52 53 54 |
# File 'lib/faussaire/music.rb', line 52 def self.variete fetch('fr.faussaire.music.variete') end |