Class: Net::IP::Route
- Inherits:
-
Object
- Object
- Net::IP::Route
- Defined in:
- lib/net/ip/route.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Route
constructor
A new instance of Route.
Constructor Details
#initialize(data) ⇒ Route
Returns a new instance of Route.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/net/ip/route.rb', line 4 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 |
Class Method Details
.all ⇒ Object
21 22 23 |
# File 'lib/net/ip/route.rb', line 21 def self.all `ip route`.split("\n").collect {|line| new(line)} end |