Class: Setuser
- Inherits:
-
Object
- Object
- Setuser
- Defined in:
- lib/setuser.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(value) ⇒ Setuser
constructor
read from config file.
-
#update ⇒ Object
update value.
Constructor Details
#initialize(value) ⇒ Setuser
read from config file
6 7 8 |
# File 'lib/setuser.rb', line 6 def initialize(value) self.user = value end |
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/setuser.rb', line 3 def user @user end |
Instance Method Details
#update ⇒ Object
update value
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/setuser.rb', line 11 def update config_path = File.("~/.loginx/config/config.yml") if File.exist?("#{config_path}") config = YAML::load (File.open("#{config_path}")) config['config']['user'] = self.user File.open("#{config_path}","w") do |file| file.write config.to_yaml file.close puts "update successfully,now default user is #{self.user}" end else puts "initialize successfully please try again" end end |