Class: Net::Openvpn::Server
- Inherits:
-
Object
- Object
- Net::Openvpn::Server
- Defined in:
- lib/net/openvpn/server.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #get(key) ⇒ Object
-
#initialize(name) ⇒ Server
constructor
A new instance of Server.
- #load ⇒ Object
- #path ⇒ Object
- #save ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize(name) ⇒ Server
Returns a new instance of Server.
5 6 7 8 |
# File 'lib/net/openvpn/server.rb', line 5 def initialize(name) @name = name load if exists? end |
Instance Method Details
#exists? ⇒ Boolean
26 27 28 |
# File 'lib/net/openvpn/server.rb', line 26 def exists? File.exists? path end |
#get(key) ⇒ Object
14 15 16 |
# File 'lib/net/openvpn/server.rb', line 14 def get(key) @config[key] end |
#load ⇒ Object
10 11 12 |
# File 'lib/net/openvpn/server.rb', line 10 def load @config = Net::Openvpn::Parser::ServerConfig.parse(File.read(path)) end |
#path ⇒ Object
22 23 24 |
# File 'lib/net/openvpn/server.rb', line 22 def path Net::Openvpn.basepath "#{@name}.conf" end |
#save ⇒ Object
30 31 32 33 34 35 |
# File 'lib/net/openvpn/server.rb', line 30 def save text = Net::Openvpn::Parser::ServerConfig.generate(@config) File.open(path, "w") do |f| f.puts text end end |
#set(key, value) ⇒ Object
18 19 20 |
# File 'lib/net/openvpn/server.rb', line 18 def set(key, value) @config[key] = value end |