Class: Yodaism::Config
- Inherits:
-
Object
- Object
- Yodaism::Config
- Defined in:
- lib/yodaism/config.rb
Constant Summary collapse
- FILE =
"#{file_path}/quotes/quotes.txt"
Instance Attribute Summary collapse
-
#quotes ⇒ Object
readonly
Returns the value of attribute quotes.
Instance Method Summary collapse
- #file ⇒ Object
- #file_not_found ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_quotes_from_file ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 |
# File 'lib/yodaism/config.rb', line 8 def initialize @quotes = {} File.exists?(file) ? load_quotes_from_file : file_not_found end |
Instance Attribute Details
#quotes ⇒ Object (readonly)
Returns the value of attribute quotes.
6 7 8 |
# File 'lib/yodaism/config.rb', line 6 def quotes @quotes end |
Instance Method Details
#file ⇒ Object
25 26 27 |
# File 'lib/yodaism/config.rb', line 25 def file FILE end |
#file_not_found ⇒ Object
13 14 15 16 |
# File 'lib/yodaism/config.rb', line 13 def file_not_found puts "could not find file in path #{FILE}" exit(1) end |
#load_quotes_from_file ⇒ Object
18 19 20 21 22 23 |
# File 'lib/yodaism/config.rb', line 18 def load_quotes_from_file f = File.new(file) f.each { |line| @quotes[f.lineno-1] = line } end |