Class: Y2Network::Widgets::Gateway

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

Instance Method Summary collapse

Constructor Details

#initialize(route) ⇒ Gateway


32
33
34
35
36
# File 'src/lib/y2network/widgets/gateway.rb', line 32

def initialize(route)
  textdomain "network"

  @route = route
end

Instance Method Details

#helpObject


42
43
44
45
46
47
# File 'src/lib/y2network/widgets/gateway.rb', line 42

def help
  _(
    "<p><b>Gateway</b> defines the IP address of a host which routes the packets " \
      "to a remote host or network. It can be blank for rejection or device routes. "
  )
end

#initObject


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

def init
  Yast::UI.ChangeWidget(Id(widget_id), :ValidChars, Yast::IP.ValidChars + "-")

  self.value = @route.gateway.nil? ? "-" : @route.gateway.to_s
end

#labelObject


38
39
40
# File 'src/lib/y2network/widgets/gateway.rb', line 38

def label
  _("&Gateway")
end

#optObject


49
50
51
# File 'src/lib/y2network/widgets/gateway.rb', line 49

def opt
  [:hstretch]
end

#storeObject


69
70
71
72
# File 'src/lib/y2network/widgets/gateway.rb', line 69

def store
  gw = value
  @route.gateway = gw == "-" ? nil : IPAddr.new(gw)
end

#validateObject


59
60
61
62
63
64
65
66
67
# File 'src/lib/y2network/widgets/gateway.rb', line 59

def validate
  return true if value == "-"

  return true if Yast::IP.Check(value)

  Yast::Popup.Error(_("Gateway IP address is invalid."))
  focus
  false
end