Class: Net::Openvpn::Host
- Inherits:
-
Object
- Object
- Net::Openvpn::Host
- Defined in:
- lib/net/openvpn/host.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
(also: #name)
readonly
Returns the value of attribute hostname.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#network ⇒ Object
Returns the value of attribute network.
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #file ⇒ Object
- #generate_key ⇒ Object
- #generate_ovpn ⇒ Object
-
#initialize(hostname, **params) ⇒ Host
constructor
A new instance of Host.
- #new? ⇒ Boolean
- #path ⇒ Object
- #remove ⇒ Object
- #save ⇒ Object
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
#hostname ⇒ Object (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 |
#ip ⇒ Object
Returns the value of attribute ip.
5 6 7 |
# File 'lib/net/openvpn/host.rb', line 5 def ip @ip end |
#network ⇒ Object
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
48 49 50 |
# File 'lib/net/openvpn/host.rb', line 48 def exist? @config.exists? end |
#file ⇒ Object
26 27 28 |
# File 'lib/net/openvpn/host.rb', line 26 def file @config.path end |
#generate_key ⇒ Object
18 19 20 |
# File 'lib/net/openvpn/host.rb', line 18 def generate_key end |
#generate_ovpn ⇒ Object
22 23 24 |
# File 'lib/net/openvpn/host.rb', line 22 def generate_ovpn end |
#new? ⇒ Boolean
44 45 46 |
# File 'lib/net/openvpn/host.rb', line 44 def new? !@config.exists? end |
#path ⇒ Object
30 31 32 |
# File 'lib/net/openvpn/host.rb', line 30 def path @config.path end |
#remove ⇒ Object
40 41 42 |
# File 'lib/net/openvpn/host.rb', line 40 def remove @config.remove end |
#save ⇒ Object
34 35 36 37 38 |
# File 'lib/net/openvpn/host.rb', line 34 def save @config.ip = ip @config.network = network @config.save end |