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.



578
579
580
581
# File 'lib/nexpose/site.rb', line 578

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

Instance Attribute Details

#fromObject

Start of range *Required



574
575
576
# File 'lib/nexpose/site.rb', line 574

def from
  @from
end

#toObject

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



576
577
578
# File 'lib/nexpose/site.rb', line 576

def to
  @to
end

Instance Method Details

#<=>(other) ⇒ Object



585
586
587
# File 'lib/nexpose/site.rb', line 585

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


589
590
591
# File 'lib/nexpose/site.rb', line 589

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

#hashObject



593
594
595
# File 'lib/nexpose/site.rb', line 593

def hash
  to_xml.hash
end

#to_xmlObject



603
604
605
# File 'lib/nexpose/site.rb', line 603

def to_xml
  to_xml_elem.to_s
end

#to_xml_elemObject



597
598
599
600
601
# File 'lib/nexpose/site.rb', line 597

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