Class: Yast::AddressClass

Inherits:
Module
  • Object
show all
Defined in:
library/types/src/modules/Address.rb

Instance Method Summary collapse

Instance Method Details

#Check(address) ⇒ Object

Check syntax of a network address (IP address or hostname)

Parameters:

  • address (String)

    an address

Returns:

  • true if correct



72
73
74
# File 'library/types/src/modules/Address.rb', line 72

def Check(address)
  Check4(address) || Check6(address)
end

#Check4(address) ⇒ Object

Check syntax of a network address (ip4 or name)

Parameters:

  • address (String)

    an address

Returns:

  • true if correct



58
59
60
# File 'library/types/src/modules/Address.rb', line 58

def Check4(address)
  IP.Check4(address) || Hostname.CheckFQ(address)
end

#Check6(address) ⇒ Object

Check syntax of a network address (ip6 or name)

Parameters:

  • address (String)

    an address

Returns:

  • true if correct



65
66
67
# File 'library/types/src/modules/Address.rb', line 65

def Check6(address)
  IP.Check6(address) || Hostname.CheckFQ(address)
end

#CheckMAC(address) ⇒ Object

Check syntax of MAC address

Parameters:

  • address (String)

    MAC address

Returns:

  • true if correct



88
89
90
91
92
93
94
95
# File 'library/types/src/modules/Address.rb', line 88

def CheckMAC(address)
  return false if address.nil? || address == ""

  regexp = "[0-9a-fA-F]{2,2}"
  regexp = Builtins.sformat("(%1:){5,5}%1", regexp)

  Builtins.regexpmatch(address, regexp)
end

#mainObject



37
38
39
40
41
42
43
44
45
46
47
# File 'library/types/src/modules/Address.rb', line 37

def main
  textdomain "base"

  Yast.import "Hostname"
  Yast.import "IP"

  @ValidChars = Ops.add(Hostname.ValidChars, IP.ValidChars)
  @ValidChars4 = Ops.add(Hostname.ValidChars, IP.ValidChars4)
  @ValidChars6 = Ops.add(Hostname.ValidChars, IP.ValidChars6)
  @ValidCharsMAC = "0123456789abcdefABCDEF:"
end

#Valid4Object

Return a description of a valid address (ip4 or name)

Returns:

  • description



51
52
53
# File 'library/types/src/modules/Address.rb', line 51

def Valid4
  Ops.add(Ops.add(IP.Valid4, "\n"), Hostname.ValidFQ)
end

#ValidMACString

Describe a valid MAC address

Returns:

  • (String)

    description of a valid MAC address



78
79
80
81
82
83
# File 'library/types/src/modules/Address.rb', line 78

def ValidMAC
  # describe valid MAC address
  _(
    "A valid MAC address consists of six pairs of hexadecimal\ndigits separated by colons."
  )
end