Class: PF::Profile
- Inherits:
-
Object
- Object
- PF::Profile
- Defined in:
- lib/pf/profile/profile.rb
Instance Attribute Summary collapse
-
#qiniu ⇒ Object
Returns the value of attribute qiniu.
Class Method Summary collapse
- .create_profile_if_not_exist ⇒ Object
- .profile ⇒ Object
- .profile_file_for_write ⇒ Object
- .profile_path ⇒ Object
- .qiniu ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Profile
constructor
A new instance of Profile.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Profile
Returns a new instance of Profile.
8 9 10 |
# File 'lib/pf/profile/profile.rb', line 8 def initialize @qiniu = QiniuProfile.new(self) end |
Instance Attribute Details
#qiniu ⇒ Object
Returns the value of attribute qiniu.
6 7 8 |
# File 'lib/pf/profile/profile.rb', line 6 def qiniu @qiniu end |
Class Method Details
.create_profile_if_not_exist ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pf/profile/profile.rb', line 23 def self.create_profile_if_not_exist path = profile_path require 'fileutils' unless File.directory?(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path)) end unless File.exist?(path) Profile.new.save end end |
.profile ⇒ Object
38 39 40 41 42 |
# File 'lib/pf/profile/profile.rb', line 38 def self.profile create_profile_if_not_exist file = profile_path YAML.load_file(file) end |
.profile_file_for_write ⇒ Object
34 35 36 |
# File 'lib/pf/profile/profile.rb', line 34 def self.profile_file_for_write File.open(profile_path, "w+") end |
.profile_path ⇒ Object
18 19 20 21 |
# File 'lib/pf/profile/profile.rb', line 18 def self.profile_path pf_home = File.join(Dir.home(), '.pf') File.join(pf_home, "profile.yaml") end |
.qiniu ⇒ Object
44 45 46 |
# File 'lib/pf/profile/profile.rb', line 44 def self.qiniu profile.qiniu end |
Instance Method Details
#save ⇒ Object
12 13 14 15 16 |
# File 'lib/pf/profile/profile.rb', line 12 def save file = self.class.profile_file_for_write file.write(to_yaml) file.close end |