module Quotify
This module generates quotes on demand. Welcome to the future.
Public Class Methods
config()
click to toggle source
Outputs the configs of quotify-ruby @return [Hash]
# File lib/quotify.rb, line 23 def self.config @config end
configure(opts = {})
click to toggle source
Configure through hash @param opts [Hash] A Hash of configurations
# File lib/quotify.rb, line 29 def self.configure(opts = {}) opts.each do |k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym end end
configure_with(path_to_yaml_file)
click to toggle source
Configure through yaml file @param path_to_yaml_file [Path] Path of the configuration file
# File lib/quotify.rb, line 37 def self.configure_with(path_to_yaml_file) begin config = YAML.load_file(path_to_yaml_file) rescue Errno::ENOENT puts "YAML configuration file couldn't be found. Using defaults."; return rescue Psych::SyntaxError puts "YAML configuration file contains invalid syntax. Using defaults."; return end configure(config) end
generate(quote: nil, author: nil)
click to toggle source
Generates a quote @param quote [#to_s] A specified quote @param author [#to_s] A specified author @return [Quotify::Quote] quote with author
# File lib/quotify.rb, line 17 def self.generate(quote: nil, author: nil) Quote.new(quote: quote, author: author) end
reset_config()
click to toggle source
Resets the configurations
# File lib/quotify.rb, line 50 def self.reset_config @config = @default_config.clone end