Class: Nexpose::IPRange
- Inherits:
-
Object
- Object
- Nexpose::IPRange
- 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
-
#from ⇒ Object
Start of range *Required.
-
#to ⇒ Object
End of range *Optional (If nil then IPRange is a single IP Address).
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(from, to = nil) ⇒ IPRange
constructor
A new instance of IPRange.
- #to_xml ⇒ Object
- #to_xml_elem ⇒ Object
Constructor Details
#initialize(from, to = nil) ⇒ IPRange
Returns a new instance of IPRange.
729 730 731 732 |
# File 'lib/nexpose/site.rb', line 729 def initialize(from, to = nil) @from = IPAddr.new(from) @to = IPAddr.new(to) if to end |
Instance Attribute Details
#from ⇒ Object
Start of range *Required
725 726 727 |
# File 'lib/nexpose/site.rb', line 725 def from @from end |
#to ⇒ Object
End of range *Optional (If nil then IPRange is a single IP Address)
727 728 729 |
# File 'lib/nexpose/site.rb', line 727 def to @to end |
Instance Method Details
#<=>(other) ⇒ Object
736 737 738 |
# File 'lib/nexpose/site.rb', line 736 def <=>(other) to_xml <=> other.to_xml end |
#eql?(other) ⇒ Boolean
740 741 742 |
# File 'lib/nexpose/site.rb', line 740 def eql?(other) to_xml == other.to_xml end |
#hash ⇒ Object
744 745 746 |
# File 'lib/nexpose/site.rb', line 744 def hash to_xml.hash end |
#to_xml ⇒ Object
754 755 756 |
# File 'lib/nexpose/site.rb', line 754 def to_xml to_xml_elem.to_s end |
#to_xml_elem ⇒ Object
748 749 750 751 752 |
# File 'lib/nexpose/site.rb', line 748 def to_xml_elem xml = REXML::Element.new('range') xml.add_attributes({'from' => @from, 'to' => @to}) xml end |