class Config
#type constant
@@MaxConnections = 3
# type fields
@@host = "10.0.0.1"
@@port = 3306
# type method
def self.getConnection
"#{@@host}:#{@@port}"
end
def self.setHost(host)
@@host = host
end
end
connection = Config.getConnection()
# connection is "10.0.0.1:3306"
puts "connection is #{connection}"
Config.setHost("10.0.0.3")
connection = Config.getConnection()
# connection is "10.0.0.3:3306"
puts "connection is #{connection}"