module Net module IP class Route def initialize(data) parts = data.split(" ") @dest = parts.first parts.each do |part| name, value = part.split(" ") if name == "metric" @metric = value elsif name == "scope" @scope = value elsif name == "proto" @proto = value elsif name == "src" @src = value end end end def self.all `ip route`.split("\n").collect {|line| new(line)} end private end end end