Class: JennCad::ProfileLoader
- Inherits:
-
Object
- Object
- JennCad::ProfileLoader
- Defined in:
- lib/jenncad/profile_loader.rb
Instance Method Summary collapse
- #check_profile ⇒ Object
-
#initialize ⇒ ProfileLoader
constructor
A new instance of ProfileLoader.
- #load_defaults ⇒ Object
- #load_profile ⇒ Object
- #profile_dir ⇒ Object
- #profile_path ⇒ Object
Constructor Details
#initialize ⇒ ProfileLoader
Returns a new instance of ProfileLoader.
3 4 5 |
# File 'lib/jenncad/profile_loader.rb', line 3 def initialize load_profile end |
Instance Method Details
#check_profile ⇒ Object
24 25 26 27 28 |
# File 'lib/jenncad/profile_loader.rb', line 24 def check_profile unless defined?($jenncad_profile) load_defaults end end |
#load_defaults ⇒ Object
30 31 32 |
# File 'lib/jenncad/profile_loader.rb', line 30 def load_defaults $jenncad_profile = JennCad::DefaultProfile.new end |
#load_profile ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/jenncad/profile_loader.rb', line 15 def load_profile if File.exists?(profile_path) require profile_path check_profile else load_defaults end end |
#profile_dir ⇒ Object
7 8 9 |
# File 'lib/jenncad/profile_loader.rb', line 7 def profile_dir File.(["~", ".config", "jenncad"].join("/")) end |
#profile_path ⇒ Object
11 12 13 |
# File 'lib/jenncad/profile_loader.rb', line 11 def profile_path [profile_dir, "profile.rb"].join("/") end |