Class: IPCat::IPRange
- Inherits:
-
Object
- Object
- IPCat::IPRange
- Defined in:
- lib/ipcat/iprange.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
Returns the value of attribute first.
-
#last ⇒ Object
Returns the value of attribute last.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #<=>(obj) ⇒ Object
-
#initialize(first, last, name = nil, url = nil) ⇒ IPRange
constructor
A new instance of IPRange.
Constructor Details
#initialize(first, last, name = nil, url = nil) ⇒ IPRange
Returns a new instance of IPRange.
6 7 8 9 10 11 |
# File 'lib/ipcat/iprange.rb', line 6 def initialize(first, last, name=nil, url=nil) @first = IPCat.ip_to_integer(first) @last = IPCat.ip_to_integer(last) @name, @url = name, url raise ArgumentError.new("first must be <= last") if @first > @last end |
Instance Attribute Details
#first ⇒ Object
Returns the value of attribute first.
4 5 6 |
# File 'lib/ipcat/iprange.rb', line 4 def first @first end |
#last ⇒ Object
Returns the value of attribute last.
4 5 6 |
# File 'lib/ipcat/iprange.rb', line 4 def last @last end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ipcat/iprange.rb', line 4 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/ipcat/iprange.rb', line 4 def url @url end |
Instance Method Details
#<=>(obj) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ipcat/iprange.rb', line 13 def <=>(obj) case obj when Integer compare_with_integer(obj) when IPRange # Assume all IPRanges are non-overlapping first <=> obj.first end end |