Class: Ncrack::XML::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/ncrack/xml/address.rb

Overview

Represents a address XML element.

Constant Summary collapse

TYPES =

Mapping of addrtype values to Symbols.

{
  'ipv4' => :ipv4,
  'ipv6' => :ipv6
}

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Address

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the address object.

Parameters:

  • node (Nokogiri::XML::Node)

    The XML node for the address XML element.



16
17
18
# File 'lib/ncrack/xml/address.rb', line 16

def initialize(node)
  @node = node
end

Instance Method Details

#addrString

The IP of the address.

Returns:

  • (String)

    The value of the addr attribute.



26
27
28
# File 'lib/ncrack/xml/address.rb', line 26

def addr
  @addr ||= @node['addr']
end

#ipv4?Boolean

Determines whether the address is IPv4 or IPv6.

Returns:

  • (Boolean)


54
55
56
# File 'lib/ncrack/xml/address.rb', line 54

def ipv4?
  type == :ipv4
end

#ipv6?Boolean

Determines whether the address is IPv6 or IPv4.

Returns:

  • (Boolean)


63
64
65
# File 'lib/ncrack/xml/address.rb', line 63

def ipv6?
  type == :ipv6
end

#to_sString

Converts the address to a String.

Returns:

  • (String)

    The IP of the address.



73
74
75
# File 'lib/ncrack/xml/address.rb', line 73

def to_s
  addr.to_s
end

#type:ipv4, ...

The IP address type.

Returns:

  • (:ipv4, :ipv6, String)

    The value of the addrtype attribute.



42
43
44
45
46
47
# File 'lib/ncrack/xml/address.rb', line 42

def type
  @type ||= (
    addrtype = @node['addrtype']
    TYPES.fetch(addrtype,addrtype)
  )
end