Class: Faussaire::Piraterie
- Inherits:
-
Object
- Object
- Faussaire::Piraterie
- Defined in:
- lib/faussaire/piraterie.rb
Constant Summary collapse
- DATA_PATH =
File.('../../../locale/fr.yml', __FILE__)
Class Method Summary collapse
-
.excuse ⇒ String
Produces a random excuse for not delivering a project or being absent.
-
.fetch(key) ⇒ Object?
Fetches and samples data based on the provided key.
-
.nav ⇒ String
Produces a random pirate boat type.
-
.pnj ⇒ String
Produces a random pirate-themed status not used in the Hacking Project.
-
.potin ⇒ String
Produces a random made-up gossip about The Hacking Project experience.
-
.rage ⇒ String
Produces a random pirate swearing.
-
.role ⇒ String
Produces a random The Hacking Project learner status.
Class Method Details
.excuse ⇒ String
Produces a random excuse for not delivering a project or being absent.
76 77 78 |
# File 'lib/faussaire/piraterie.rb', line 76 def self.excuse fetch('fr.faussaire.piraterie.excuse') end |
.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/piraterie.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 |
.nav ⇒ String
Produces a random pirate boat type.
52 53 54 |
# File 'lib/faussaire/piraterie.rb', line 52 def self.nav fetch('fr.faussaire.piraterie.nav') end |
.pnj ⇒ String
Produces a random pirate-themed status not used in the Hacking Project.
40 41 42 |
# File 'lib/faussaire/piraterie.rb', line 40 def self.pnj fetch('fr.faussaire.piraterie.pnj') end |
.potin ⇒ String
Produces a random made-up gossip about The Hacking Project experience.
88 89 90 |
# File 'lib/faussaire/piraterie.rb', line 88 def self.potin fetch('fr.faussaire.piraterie.potin') end |
.rage ⇒ String
Produces a random pirate swearing.
64 65 66 |
# File 'lib/faussaire/piraterie.rb', line 64 def self.rage fetch('fr.faussaire.piraterie.rage') end |
.role ⇒ String
Produces a random The Hacking Project learner status.
28 29 30 |
# File 'lib/faussaire/piraterie.rb', line 28 def self.role fetch('fr.faussaire.piraterie.role') end |