Class: Pow::Profile
- Inherits:
-
Object
- Object
- Pow::Profile
- Defined in:
- lib/pow/profile.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#profile_path ⇒ Object
Returns the value of attribute profile_path.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#yaml ⇒ Object
readonly
Returns the value of attribute yaml.
Instance Method Summary collapse
-
#initialize(profile_path = :default) ⇒ Profile
constructor
A new instance of Profile.
- #inspect ⇒ Object
- #preview ⇒ Object
- #read ⇒ Object
- #write ⇒ Object (also: #save)
Constructor Details
#initialize(profile_path = :default) ⇒ Profile
Returns a new instance of Profile.
10 11 12 13 14 |
# File 'lib/pow/profile.rb', line 10 def initialize(profile_path=:default) @profile_path = (profile_path == :default) ? File.("~/.pow_defaults") : profile_path @settings = read if File.exists?(@profile_path) @name = "Default" end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/pow/profile.rb', line 7 def name @name end |
#profile_path ⇒ Object
Returns the value of attribute profile_path.
7 8 9 |
# File 'lib/pow/profile.rb', line 7 def profile_path @profile_path end |
#settings ⇒ Object
Returns the value of attribute settings.
7 8 9 |
# File 'lib/pow/profile.rb', line 7 def settings @settings end |
#yaml ⇒ Object (readonly)
Returns the value of attribute yaml.
8 9 10 |
# File 'lib/pow/profile.rb', line 8 def yaml @yaml end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/pow/profile.rb', line 31 def inspect "<Pow::Profile '#{name}'>" end |
#preview ⇒ Object
35 36 37 38 |
# File 'lib/pow/profile.rb', line 35 def preview opts = {:text => "Hello world!"}.merge( settings ) Puts.new( opts ).out! end |
#read ⇒ Object
23 24 25 |
# File 'lib/pow/profile.rb', line 23 def read @yaml = YAML.load_file( profile_path ) end |
#write ⇒ Object Also known as: save
16 17 18 19 20 |
# File 'lib/pow/profile.rb', line 16 def write FileUtils.mkdir_p( File.dirname(profile_path) ) File.open( profile_path, 'wb'){|f| YAML.dump( settings, f ) } read end |