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:

  • (String)

Available since:

  • 1.9.1



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:

  • (String)

Available since:

  • 1.9.1



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:

  • (String)

Available since:

  • 1.6.4



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:

  • (Array<String>)

Available since:

  • 1.6.4



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:

  • (String)

Available since:

  • 1.9.1



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:

  • (String)

Available since:

  • 1.6.4



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:

  • (String)

Available since:

  • 1.6.4



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:

  • (Array<String>)

Available since:

  • 1.6.4



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:

  • (Array<String>)

Available since:

  • 1.6.4



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:

  • (Array<String>)

Available since:

  • 1.6.4



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:

  • (String)

Available since:

  • next



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

def mambo_no_5
  fetch('music.mambo_no_5')
end