Class: TED::Config
- Inherits:
-
Object
- Object
- TED::Config
- Defined in:
- lib/config.rb
Instance Method Summary collapse
- #changeIP(ip) ⇒ Object
- #changePort(port) ⇒ Object
- #close ⇒ Object
- #getIP ⇒ Object
- #getPort ⇒ Object
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
- #save ⇒ Object
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/config.rb', line 3 def initialize(path) exist = File.file?(path) if exist File.open(path,"r").each do |l| p = l.split(",") @ip = p[0] @port = p[1].to_i end @file = File.open(path, "w+") else @file = File.open(path, "a+") @ip = "localhost" @port = 3030 save end end |
Instance Method Details
#changeIP(ip) ⇒ Object
30 31 32 33 |
# File 'lib/config.rb', line 30 def changeIP(ip) @ip=ip save end |
#changePort(port) ⇒ Object
25 26 27 28 |
# File 'lib/config.rb', line 25 def changePort(port) @port=port.to_i save end |
#close ⇒ Object
43 44 45 46 |
# File 'lib/config.rb', line 43 def close save @file.close end |
#getIP ⇒ Object
35 36 37 |
# File 'lib/config.rb', line 35 def getIP return @ip end |
#getPort ⇒ Object
39 40 41 |
# File 'lib/config.rb', line 39 def getPort return @port.to_i end |
#save ⇒ Object
20 21 22 23 |
# File 'lib/config.rb', line 20 def save @file.rewind @file.puts("#{@ip},#{@port}") end |