Class: Aaron::Aaron
- Inherits:
-
Object
- Object
- Aaron::Aaron
- Defined in:
- lib/aaron.rb
Constant Summary collapse
- @@possible_config_file_locations =
%w[ ~/aaron.rb ].map { |f| File.(f) }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #get_binding ⇒ Object
-
#initialize(config, file = nil) ⇒ Aaron
constructor
A new instance of Aaron.
- #run ⇒ Object
Constructor Details
#initialize(config, file = nil) ⇒ Aaron
Returns a new instance of Aaron.
43 44 45 46 |
# File 'lib/aaron.rb', line 43 def initialize config, file = nil @config = config @file = file end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/aaron.rb', line 16 def config @config end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
16 17 18 |
# File 'lib/aaron.rb', line 16 def file @file end |
Class Method Details
.from_file(file) ⇒ Object
39 40 41 |
# File 'lib/aaron.rb', line 39 def self.from_file file Aaron.new(File.read(file), file) end |
.locate_config_file ⇒ Object
22 23 24 |
# File 'lib/aaron.rb', line 22 def self.locate_config_file @@possible_config_file_locations.find { |p| File.exists?(p) } end |
.run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aaron.rb', line 26 def self.run config_file = Aaron.locate_config_file if config_file Aaron.from_file(config_file).run else raise Errors::ConfigFileNotFound.new %Q( Aaron was unable to locate his config file. He looked in #{@@possible_config_file_locations.join("\n")} ) end end |