Class: Y2Network::Widgets::Netmask

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

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Netmask


30
31
32
33
34
# File 'src/lib/y2network/widgets/netmask.rb', line 30

def initialize(settings)
  textdomain "network"

  @settings = settings
end

Instance Method Details

#helpObject


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

def help
  # TODO: write it
  ""
end

#initObject


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

def init
  self.value = @settings.subnet_prefix
end

#labelObject


36
37
38
# File 'src/lib/y2network/widgets/netmask.rb', line 36

def label
  _("&Subnet Mask")
end

#optObject


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

def opt
  [:hstretch]
end

#storeObject


53
54
55
# File 'src/lib/y2network/widgets/netmask.rb', line 53

def store
  @settings.subnet_prefix = value
end

#valid_netmaskObject


65
66
67
68
69
70
71
72
73
74
# File 'src/lib/y2network/widgets/netmask.rb', line 65

def valid_netmask
  mask = value
  mask = mask[1..-1] if mask.start_with?("/")

  if Yast::Netmask.Check4(mask) || Yast::Netmask.CheckPrefix4(mask) || Yast::Netmask.Check6(mask)
    return true
  end

  false
end

#validateObject


57
58
59
60
61
62
63
# File 'src/lib/y2network/widgets/netmask.rb', line 57

def validate
  return true if valid_netmask

  Yast::Popup.Error(_("No valid netmask or prefix length."))
  focus
  false
end