Class: Y2Network::Widgets::Devices

Inherits:
CWM::ComboBox
  • Object
show all
Defined in:
src/lib/y2network/widgets/devices.rb

Instance Method Summary collapse

Constructor Details

#initialize(route, available_devices) ⇒ Devices

Returns a new instance of Devices.

Parameters:

  • route

    route object to get and store gateway value


27
28
29
30
31
32
# File 'src/lib/y2network/widgets/devices.rb', line 27

def initialize(route, available_devices)
  textdomain "network"

  @devices = available_devices
  @route = route
end

Instance Method Details

#helpObject


38
39
40
41
42
43
# File 'src/lib/y2network/widgets/devices.rb', line 38

def help
  _(
    "<p><b>Device</b> specifies the device through which the traffic" \
      " to the defined network will be routed.</p>"
  )
end

#initObject


54
55
56
57
# File 'src/lib/y2network/widgets/devices.rb', line 54

def init
  interface = @route.interface
  self.value = interface ? interface.name : ""
end

#itemsObject


45
46
47
48
# File 'src/lib/y2network/widgets/devices.rb', line 45

def items
  # TODO: maybe some translated names?
  @devices.map { |d| [d, d] }
end

#labelObject


34
35
36
# File 'src/lib/y2network/widgets/devices.rb', line 34

def label
  _("De&vice")
end

#optObject


50
51
52
# File 'src/lib/y2network/widgets/devices.rb', line 50

def opt
  [:hstretch, :editable]
end

#storeObject


59
60
61
62
# File 'src/lib/y2network/widgets/devices.rb', line 59

def store
  interface = value
  @route.interface = interface.empty? ? nil : Interface.new(interface)
end