Module: Cornflake::MacAddress
- Defined in:
- lib/cornflake/mac.rb
Constant Summary collapse
- RE =
%r/(?:[^:\-]|\A)(?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F](?:[^:\-]|\Z)/io
Class Method Summary collapse
Class Method Details
.find ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cornflake/mac.rb', line 7 def self.find cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'cat /sys/class/net/*/address' cmds.each do |cmd| mac = parse_mac_output(`#{cmd}`) return mac if mac end # Not found; randomize a mac address SecureRandom.hex(6).scan(/.{2}/).join(':') end |