module HaarJoke
This module contains a Joke
class for creating jokes featuring the fire Emblem Haar (using Chuck Norris jokes from api.icndb.com). It also contains a method for creating a joke and getting returning the joke
Constants
- VERSION
Public Class Methods
create_custom_joke()
click to toggle source
user can create joke with their own file
# File lib/haar_joke.rb, line 22 def self.create_custom_joke @config = use_custom_file create_joke end
create_joke()
click to toggle source
user can create joke with custom settings
# File lib/haar_joke.rb, line 16 def self.create_joke joke = Joke.new joke.text end
Private Class Methods
config()
click to toggle source
# File lib/haar_joke.rb, line 37 def self.config @config end
use_custom_file()
click to toggle source
# File lib/haar_joke.rb, line 29 def self.use_custom_file file_path = Rails.root.join('config/haar_joke.yml') YAML.load_file(file_path) rescue raise 'YAML file missing. Custom method requires a config/haar_joke.yml file. For non custom jokes, use HaarJoke.create_joke' end