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
33
# File 'src/lib/y2network/widgets/devices.rb', line 27

def initialize(route, available_devices)
  super()
  textdomain "network"

  @devices = available_devices
  @route = route
end

Instance Method Details

#helpObject



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

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

#initObject



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

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

#itemsObject



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

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

#labelObject



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

def label
  _("De&vice")
end

#optObject



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

def opt
  [:hstretch, :editable]
end

#storeObject



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

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