Class: Y2Network::Widgets::Hostname

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

Overview

Widget that permits to modify the hostname of the given object

Instance Method Summary collapse

Constructor Details

#initialize(settings, empty_allowed: true) ⇒ Hostname

Constructor

Parameters:

  • settings (Object)
  • empty_allowed (Boolean) (defaults to: true)

    whether an empty hostname should be valid or not


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

def initialize(settings, empty_allowed: true)
  textdomain "network"

  @settings = settings
  @empty_allowed = empty_allowed
end

Instance Method Details

#initObject


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

def init
  self.value = @settings.hostname.to_s
end

#labelObject


42
43
44
# File 'src/lib/y2network/widgets/hostname.rb', line 42

def label
  _("&Hostname")
end

#storeObject


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

def store
  @settings.hostname = value
end

#validateObject


50
51
52
53
54
55
# File 'src/lib/y2network/widgets/hostname.rb', line 50

def validate
  Yast.import "Hostname"
  return true if empty_allowed? && value.to_s.empty?

  Yast::Hostname.CheckFQ(value)
end