Class: Setport

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Setport

read from config file



6
7
8
# File 'lib/setport.rb', line 6

def initialize(value)
  self.port = value
end

Instance Attribute Details

#portObject

Returns the value of attribute port.



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

def port
  @port
end

Instance Method Details

#updateObject

update value



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/setport.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']['port'] = self.port
    File.open("#{config_path}","w") do |file|
      file.write config.to_yaml
      file.close
      puts "update successfully,now default user is #{self.port}"
    end
  else
    puts "initialize successfully please try again"
  end
end