Class: Nexpose::IPRange

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/nexpose/site.rb

Overview

Description

Object that represents a single IP address or an inclusive range of IP addresses. If to is nil then the from field will be used to specify a single IP Address only.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to = nil) ⇒ IPRange

Returns a new instance of IPRange.



797
798
799
800
# File 'lib/nexpose/site.rb', line 797

def initialize(from, to = nil)
  @from = IPAddr.new(from)
  @to = IPAddr.new(to) if to
end

Instance Attribute Details

#fromObject

Start of range *Required



793
794
795
# File 'lib/nexpose/site.rb', line 793

def from
  @from
end

#toObject

End of range *Optional (If nil then IPRange is a single IP Address)



795
796
797
# File 'lib/nexpose/site.rb', line 795

def to
  @to
end

Instance Method Details

#<=>(other) ⇒ Object



804
805
806
# File 'lib/nexpose/site.rb', line 804

def <=>(other)
  to_xml <=> other.to_xml
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


808
809
810
# File 'lib/nexpose/site.rb', line 808

def eql?(other)
  to_xml == other.to_xml
end

#hashObject



812
813
814
# File 'lib/nexpose/site.rb', line 812

def hash
  to_xml.hash
end

#to_xmlObject



822
823
824
# File 'lib/nexpose/site.rb', line 822

def to_xml
  to_xml_elem.to_s
end

#to_xml_elemObject



816
817
818
819
820
# File 'lib/nexpose/site.rb', line 816

def to_xml_elem
  xml = REXML::Element.new('range')
  xml.add_attributes({'from' => @from, 'to' => @to})
  xml
end