Class: Jamf::IPAddress

Inherits:
IPAddr show all
Defined in:
lib/jamf/api/attribute_classes/ip_address.rb

Overview

A wrapper for IPAddr - allowing initialize to take an unused cnx: and providing #to_jamf

Instance Method Summary collapse

Constructor Details

#initialize(an_ip, cnx: nil) ⇒ IPAddress

Returns a new instance of IPAddress.

Parameters:

  • an_ip (String, IPAddr)
  • cnx (void) (defaults to: nil)

    unused, but required



45
46
47
48
49
50
51
52
53
54
# File 'lib/jamf/api/attribute_classes/ip_address.rb', line 45

def initialize(an_ip, cnx: nil)
  cnx.to_s # shutup rubocop.

  if an_ip.nil?
    @empty_ip = true
    return
  end

  super an_ip
end

Instance Method Details

#to_jamfString

Returns the IP formatted for passing to the API as a string.

Returns:

  • (String)

    the IP formatted for passing to the API as a string.



58
59
60
61
# File 'lib/jamf/api/attribute_classes/ip_address.rb', line 58

def to_jamf
  return Jamf::BLANK if @empty_ip
  to_s
end