ieeemac.rb, why let python have all the fun?
I was a little bored tonight and thought I’d respond to a post over Happy Python with some code. Thanks for the inspiration Matt!
ruby>> require 'ieeemac'
# => true
ruby>> macs = Mac.find_macs `ifconfig -a`
# => [#<Mac:0x1357f40 @mac=["00", "16", "cb", "95", "13", "50"]>, #<Mac:0x1357f2c @mac=["00", "16", "cb", "ff", "fe", "5d"]>, #<Mac:0x1357d74 @mac=["00", "17", "f2", "41", "ec", "ec"]>, #<Mac:0x1357c20 @mac=["00", "50", "56", "c0", "00", "08"]>, #<Mac:0x1357ae0 @mac=["00", "50", "56", "c0", "00", "01"]>, #<Mac:0x135798c @mac=["00", "1c", "42", "00", "00", "00"]>, #<Mac:0x13577e8 @mac=["00", "1c", "42", "00", "00", "01"]>]
ruby>> macs[0].to_format :cisco
# => "0016.cb95.1350"
ruby>> macs[0].to_cisco
# => "0016.cb95.1350" Read the rest of this post for the full class.
Posted in Ruby | 2 comments |