Class: Net::Openvpn::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/net/openvpn/host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, **params) ⇒ Host

Returns a new instance of Host.



9
10
11
12
13
14
15
16
# File 'lib/net/openvpn/host.rb', line 9

def initialize(hostname, **params)
  @hostname = hostname
  @config = Net::Openvpn::ClientConfig.new(@hostname)

  params.each do |key, value|
    self.send("#{key}=".to_sym, value)
  end
end

Instance Attribute Details

#hostnameObject (readonly) Also known as: name

Returns the value of attribute hostname.



6
7
8
# File 'lib/net/openvpn/host.rb', line 6

def hostname
  @hostname
end

#ipObject

Returns the value of attribute ip.



5
6
7
# File 'lib/net/openvpn/host.rb', line 5

def ip
  @ip
end

#networkObject

Returns the value of attribute network.



5
6
7
# File 'lib/net/openvpn/host.rb', line 5

def network
  @network
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/net/openvpn/host.rb', line 48

def exist?
  @config.exists?
end

#fileObject



26
27
28
# File 'lib/net/openvpn/host.rb', line 26

def file
  @config.path
end

#generate_keyObject



18
19
20
# File 'lib/net/openvpn/host.rb', line 18

def generate_key

end

#generate_ovpnObject



22
23
24
# File 'lib/net/openvpn/host.rb', line 22

def generate_ovpn

end

#new?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/net/openvpn/host.rb', line 44

def new?
  !@config.exists?
end

#pathObject



30
31
32
# File 'lib/net/openvpn/host.rb', line 30

def path
  @config.path
end

#removeObject



40
41
42
# File 'lib/net/openvpn/host.rb', line 40

def remove
  @config.remove
end

#saveObject



34
35
36
37
38
# File 'lib/net/openvpn/host.rb', line 34

def save
  @config.ip = ip
  @config.network = network
  @config.save
end