Class: PF::Profile
- Inherits:
-
Object
- Object
- PF::Profile
- Defined in:
- lib/pf/profile/profile.rb
Instance Attribute Summary collapse
-
#box ⇒ Object
Returns the value of attribute box.
-
#qiniu ⇒ Object
Returns the value of attribute qiniu.
Class Method Summary collapse
- .box ⇒ Object
- .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 11 |
# File 'lib/pf/profile/profile.rb', line 8 def initialize @qiniu = QiniuProfile.new(self) @box = BoxProfile.new(self) end |
Instance Attribute Details
#box ⇒ Object
Returns the value of attribute box.
6 7 8 |
# File 'lib/pf/profile/profile.rb', line 6 def box @box end |
#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
.box ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/pf/profile/profile.rb', line 49 def self.box p = profile if p.box.nil? p.box = BoxProfile.new(p) end p.save p.box end |
.create_profile_if_not_exist ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pf/profile/profile.rb', line 24 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
39 40 41 42 43 |
# File 'lib/pf/profile/profile.rb', line 39 def self.profile create_profile_if_not_exist file = profile_path YAML.load_file(file) end |
.profile_file_for_write ⇒ Object
35 36 37 |
# File 'lib/pf/profile/profile.rb', line 35 def self.profile_file_for_write File.open(profile_path, "w+") end |
.profile_path ⇒ Object
19 20 21 22 |
# File 'lib/pf/profile/profile.rb', line 19 def self.profile_path pf_home = File.join(Dir.home(), '.pf') File.join(pf_home, "profile.yaml") end |
.qiniu ⇒ Object
45 46 47 |
# File 'lib/pf/profile/profile.rb', line 45 def self.qiniu profile.qiniu end |
Instance Method Details
#save ⇒ Object
13 14 15 16 17 |
# File 'lib/pf/profile/profile.rb', line 13 def save file = self.class.profile_file_for_write file.write(to_yaml) file.close end |