Class: Faussaire::Tv

Inherits:
Object
  • Object
show all
Defined in:
lib/faussaire/tv.rb

Defined Under Namespace

Modules: FestivalCannes

Constant Summary collapse

DATA_PATH =
File.expand_path('../../../locale/fr.yml', __FILE__)

Class Method Summary collapse

Class Method Details

.channelString

Produces a random TV channel name.

Examples:

Faussaire::Tv.channel #=> "HBO"

Returns:

  • (String)


169
170
171
# File 'lib/faussaire/tv.rb', line 169

def self.channel
  fetch('fr.faussaire.tv.channel')
end

.famous_couplesString

Produces a random famous couple from television.

Examples:

Faussaire::Tv.famous_couples #=> "Ross and Rachel"

Returns:

  • (String)


157
158
159
# File 'lib/faussaire/tv.rb', line 157

def self.famous_couples
  fetch('fr.faussaire.tv.famous_couples')
end

.festival_cannesObject



121
122
123
# File 'lib/faussaire/tv.rb', line 121

def self.festival_cannes
  FestivalCannes
end

.fetch(key) ⇒ Object?

Fetches and samples data from the YAML file based on the provided key. If the data is an array, it samples a single item.

Parameters:

  • key (String)

    The dot-separated key used to access the data.

Returns:

  • (Object, nil)

    The data fetched and optionally sampled.



115
116
117
118
119
# File 'lib/faussaire/tv.rb', line 115

def self.fetch(key)
  data = YAML.load_file(DATA_PATH)
  result = data.dig(*key.split('.'))
  result.is_a?(Array) ? result.sample : result
end

.influencerString

Produces a random famous influencer’s name.

Examples:

Faussaire::Tv.influencer #=> "Kim Kardashian"

Returns:

  • (String)


145
146
147
# File 'lib/faussaire/tv.rb', line 145

def self.influencer
  fetch('fr.faussaire.tv.influencer')
end

.netflixString

Produces a random Netflix program.

Examples:

Faussaire::Tv.netflix #=> "Stranger Things"

Returns:

  • (String)


181
182
183
# File 'lib/faussaire/tv.rb', line 181

def self.netflix
  fetch('fr.faussaire.tv.netflix')
end

.showString

Produces a random television show title.

Examples:

Faussaire::Tv.show #=> "Game of Thrones"

Returns:

  • (String)


133
134
135
# File 'lib/faussaire/tv.rb', line 133

def self.show
  fetch('fr.faussaire.tv.show')
end