Class: Setuser

Inherits:
Object
  • Object
show all
Defined in:
lib/setuser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#userObject

Returns the value of attribute user.



3
4
5
# File 'lib/setuser.rb', line 3

def user
  @user
end

Instance Method Details

#updateObject

update value



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/setuser.rb', line 11

def update
  config_path = File.expand_path("~/.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