Class: Faker::Music

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/music/opera.rb,
lib/faker/music/rush.rb,
lib/faker/music/music.rb,
lib/faker/music/phish.rb,
lib/faker/music/hiphop.rb,
lib/faker/music/prince.rb,
lib/faker/music/pearl_jam.rb,
lib/faker/music/rock_band.rb,
lib/faker/music/grateful_dead.rb,
lib/faker/music/umphreys_mcgee.rb,
lib/faker/music/smashing_pumpkins.rb

Overview

A generator of titles of operas by various composers

Defined Under Namespace

Classes: GratefulDead, Hiphop, Opera, PearlJam, Phish, Prince, RockBand, Rush, SmashingPumpkins, UmphreysMcgee

Constant Summary collapse

NOTE_LETTERS =
%w[C D E F G A B].freeze
ACCIDENTAL_SIGNS =
['b', '#', ''].freeze
KEY_TYPES =
['', 'm'].freeze
CHORD_TYPES =
['', 'maj', '6', 'maj7', 'm', 'm7', '-7', '7', 'dom7', 'dim', 'dim7', 'm7b5'].freeze

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.albumString

Produces the name of an album.

Examples:

Faker::Music.album #=> "Sgt. Pepper's Lonely Hearts Club"

Returns:



115
116
117
# File 'lib/faker/music/music.rb', line 115

def album
  fetch('music.albums')
end

.bandString

Produces the name of a band.

Examples:

Faker::Music.band #=> "The Beatles"

Returns:



102
103
104
# File 'lib/faker/music/music.rb', line 102

def band
  fetch('music.bands')
end

.chordString

Produces the name of a chord, using letter notation.

Examples:

Faker::Music.chord #=> "Adim7"

Returns:



33
34
35
# File 'lib/faker/music/music.rb', line 33

def chord
  key + sample(chord_types)
end

.chord_typesArray<String>

Produces an array of types of chords.

Returns:



89
90
91
# File 'lib/faker/music/music.rb', line 89

def chord_types
  CHORD_TYPES
end

.genreString

Produces the name of a musical genre.

Examples:

Faker::Music.genre #=> "Rock"

Returns:



128
129
130
# File 'lib/faker/music/music.rb', line 128

def genre
  fetch('music.genres')
end

.instrumentString

Produces the name of an instrument.

Examples:

Faker::Music.instrument #=> "Acoustic Guitar"

Returns:



46
47
48
# File 'lib/faker/music/music.rb', line 46

def instrument
  fetch('music.instruments')
end

.keyString

Produces the name of a key/note, using letter notation.

Examples:

Faker::Music.key #=> "A#"

Returns:



20
21
22
# File 'lib/faker/music/music.rb', line 20

def key
  sample(keys) + sample(key_variants)
end

.key_typesArray<String>

Produces an array of key types (with “major” denoted as an empty string).

Examples:

Faker::Music.key_types #=> ['', 'm']

Returns:



79
80
81
# File 'lib/faker/music/music.rb', line 79

def key_types
  KEY_TYPES
end

.key_variantsArray<String>

Produces an array of accidentals (with “natural” denoted as an empty string).

Returns:



66
67
68
# File 'lib/faker/music/music.rb', line 66

def key_variants
  ACCIDENTAL_SIGNS
end

.keysArray<String>

Produces an array of the letter names of musical notes, without accidentals.

Returns:



56
57
58
# File 'lib/faker/music/music.rb', line 56

def keys
  NOTE_LETTERS
end

.mambo_no_5String

Produces a name from Lou Bega’s Mambo #5

Examples:

Faker::Music.mambo #=> "Monica"

Returns:



140
141
142
# File 'lib/faker/music/music.rb', line 140

def mambo_no_5
  fetch('music.mambo_no_5')
end