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
37
# File 'src/lib/y2network/widgets/hostname.rb', line 31

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

  @settings = settings
  @empty_allowed = empty_allowed
end

Instance Method Details

#initObject



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

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

#labelObject



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

def label
  _("&Hostname")
end

#storeObject



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

def store
  @settings.hostname = value
end

#validateObject



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

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

  Yast::Hostname.CheckFQ(value)
end