Class: VagrantDarwinSMB::Cap::ChooseAddressableIpAddr

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-darwin-smb/cap/choose_addressable_ip_addr.rb

Class Method Summary collapse

Class Method Details

.choose_addressable_ip_addr(machine, possible) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/vagrant-darwin-smb/cap/choose_addressable_ip_addr.rb', line 4

def self.choose_addressable_ip_addr(machine, possible)
  machine.communicate.tap do |comm|
    possible.each do |ip|
      command = "ping -c1 -t1 #{ip}"
      if comm.test(command)
        return ip
      end
    end
  end
  nil
end