Class: FortunesApp
Defined Under Namespace
Classes: Fortune
Instance Method Summary collapse
Instance Method Details
#extract_sample ⇒ Object
29 30 31 |
# File 'lib/fortunes.rb', line 29 def extract_sample -> (file_content) {Fortune.new(file_content.sample[0]).} end |
#generate_json ⇒ Object
33 34 35 |
# File 'lib/fortunes.rb', line 33 def generate_json -> () {JSON.generate({:message=> })} end |
#read_file(file_name) ⇒ Object
24 25 26 27 |
# File 'lib/fortunes.rb', line 24 def read_file(file_name) fortune_path = File.join( File.dirname(__FILE__), "fortunes/#{file_name}" ) File.open(fortune_path).read.scan(/((?<=%).+?(?=%))/m) end |