class SalesQuotes
Attributes
quotes[R]
Public Class Methods
new()
click to toggle source
# File lib/sales_quotes.rb, line 10 def initialize @quotes = symbolize_array(YAML.load_file("#{__dir__}/quotes.yaml")["quotes"]) end
random()
click to toggle source
# File lib/sales_quotes.rb, line 6 def self.random SalesQuotes.new.quotes.sample end
Private Instance Methods
symbolize_array(array)
click to toggle source
# File lib/sales_quotes.rb, line 16 def symbolize_array array array.map {|a| symbolize_keys(a) } end
symbolize_keys(hash)
click to toggle source
# File lib/sales_quotes.rb, line 20 def symbolize_keys hash new_hash = {} hash.each do |key, value| new_hash[key.to_sym] = value end new_hash end