Class: Y2Network::Widgets::RoutingTable
- Inherits:
-
CWM::Table
- Object
- CWM::Table
- Y2Network::Widgets::RoutingTable
- Defined in:
- src/lib/y2network/widgets/routing_table.rb
Instance Method Summary collapse
- #add_route(route) ⇒ Object
- #config ⇒ Object
-
#delete_route ⇒ Object
deletes selected route.
- #header ⇒ Object
-
#init ⇒ Object
TODO: just workaround to make it work with old hash based CWM.
-
#initialize(routing_table) ⇒ RoutingTable
constructor
A new instance of RoutingTable.
- #items ⇒ Object
- #redraw_table ⇒ Object
-
#replace_route(route) ⇒ Object
Replaces selected route with new one.
- #selected_route ⇒ Object
Constructor Details
#initialize(routing_table) ⇒ RoutingTable
Returns a new instance of RoutingTable.
31 32 33 34 35 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 31 def initialize(routing_table) textdomain "network" @routing_table = routing_table end |
Instance Method Details
#add_route(route) ⇒ Object
72 73 74 75 76 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 72 def add_route(route) @routing_table.routes << route redraw_table end |
#config ⇒ Object
96 97 98 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 96 def config Yast::Lan.yast_config end |
#delete_route ⇒ Object
deletes selected route
86 87 88 89 90 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 86 def delete_route @routing_table.routes.delete_at(value) redraw_table end |
#header ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 37 def header [ _("Destination"), _("Gateway"), _("Device"), Yast::Label.Options.delete("&") ] end |
#init ⇒ Object
TODO: just workaround to make it work with old hash based CWM
61 62 63 64 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 61 def init redraw_table disable if config.backend?(:network_manager) end |
#items ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 46 def items @routing_table.routes.map.each_with_index do |route, index| [ index, route.to.yield_self do |to| (to == :default) ? "default" : (to.to_s + "/" + to.prefix.to_s) end, route.gateway.nil? ? "-" : route.gateway.to_s, route.interface.nil? ? "-" : route.interface.name, route..to_s ] end end |
#redraw_table ⇒ Object
92 93 94 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 92 def redraw_table change_items(items) end |
#replace_route(route) ⇒ Object
Replaces selected route with new one
79 80 81 82 83 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 79 def replace_route(route) @routing_table.routes[value] = route redraw_table end |
#selected_route ⇒ Object
66 67 68 69 70 |
# File 'src/lib/y2network/widgets/routing_table.rb', line 66 def selected_route return nil unless value @routing_table.routes[value] end |