Class: VagrantPlugins::Invade::InvadeModule::Network::Private
- Inherits:
-
InvadeModule
- Object
- InvadeModule
- VagrantPlugins::Invade::InvadeModule::Network::Private
- Defined in:
- lib/vagrant-invade/module/network/private/private.rb
Instance Attribute Summary collapse
-
#machine_name ⇒ Object
Returns the value of attribute machine_name.
-
#private_network_data ⇒ Object
Returns the value of attribute private_network_data.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(machine_name, private_network_data, result: nil) ⇒ Private
constructor
A new instance of Private.
Methods inherited from InvadeModule
Constructor Details
#initialize(machine_name, private_network_data, result: nil) ⇒ Private
Returns a new instance of Private.
13 14 15 16 17 |
# File 'lib/vagrant-invade/module/network/private/private.rb', line 13 def initialize(machine_name, private_network_data, result: nil) @machine_name = machine_name @private_network_data = private_network_data @result = result end |
Instance Attribute Details
#machine_name ⇒ Object
Returns the value of attribute machine_name.
11 12 13 |
# File 'lib/vagrant-invade/module/network/private/private.rb', line 11 def machine_name @machine_name end |
#private_network_data ⇒ Object
Returns the value of attribute private_network_data.
11 12 13 |
# File 'lib/vagrant-invade/module/network/private/private.rb', line 11 def private_network_data @private_network_data end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
10 11 12 |
# File 'lib/vagrant-invade/module/network/private/private.rb', line 10 def result @result end |
Instance Method Details
#build ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vagrant-invade/module/network/private/private.rb', line 19 def build b = binding # Delete all nil keys @private_network_data.compact ip = @private_network_data['ip'] # Handle IP address exceptions if ip @private_network_data.delete('type') # Netmask only makes sense if IP is ipv6 if @private_network_data['netmask'] && !IPAddr.new(ip).ipv6? @private_network_data.delete('netmask') end end begin # Get machine name machine_name = @machine_name network_data = @private_network_data eruby = Erubis::Eruby.new(File.read(self.get_template_path(__FILE__))) @result = eruby.result b rescue TypeError, SyntaxError, SystemCallError => e raise(e) end end |