mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Seperated hostname and port config data from Config into Settings
This commit is contained in:
24
lib/settings.rb
Normal file
24
lib/settings.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
module TAC
|
||||
class Settings
|
||||
attr_accessor :hostname, :port
|
||||
def initialize
|
||||
parse(File.read(TAC::SETTINGS_PATH))
|
||||
end
|
||||
|
||||
def parse(json)
|
||||
data = JSON.parse(json, symbolize_names: true)
|
||||
|
||||
@hostname = data[:data][:hostname]
|
||||
@port = data[:data][:port]
|
||||
end
|
||||
|
||||
def to_json(*args)
|
||||
{
|
||||
data: {
|
||||
hostname: @hostname,
|
||||
port: @port,
|
||||
}
|
||||
}.to_json(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user