Class: QuoteImporter
- Inherits:
-
Object
- Object
- QuoteImporter
- Defined in:
- lib/rack/quote_importer.rb
Instance Method Summary collapse
-
#initialize ⇒ QuoteImporter
constructor
A new instance of QuoteImporter.
- #random ⇒ Object
Constructor Details
#initialize ⇒ QuoteImporter
Returns a new instance of QuoteImporter.
2 3 4 5 6 7 8 9 10 |
# File 'lib/rack/quote_importer.rb', line 2 def initialize @quotes = [] Dir.glob('fixtures/*.txt').each do |file| f = File.open(file) f.each_line do |line| @quotes << line.chomp end end end |
Instance Method Details
#random ⇒ Object
12 13 14 |
# File 'lib/rack/quote_importer.rb', line 12 def random @quotes.shuffle.first end |