I do not think that there is a built-in Ruby function to get this address; you may have to make a system call to list the value (for example, ifconfigon UNIX, ipconfig /allon Win32) and analyze the output as needed.
Something like this (unverified pseudocode):
def mac_address
platform = RUBY_PLATFORM.downcase
output = `#{(platform =~ /win32/) ? 'ipconfig /all' : 'ifconfig'}`
case platform
when /darwin/
$1 if output =~ /en1.*?(([A-F0-9]{2}:){5}[A-F0-9]{2})/im
when /win32/
$1 if output =~ /Physical Address.*?(([A-F0-9]{2}-){5}[A-F0-9]{2})/im
else nil
end
end
source
share