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.
7 8 9 10 11 12 13 |
# File 'lib/ipcat/iprange.rb', line 7 def initialize(first, last, name = nil, url = nil) @first = IPCat.ip_to_integer(first) @last = IPCat.ip_to_integer(last) @name = name @url = url raise ArgumentError, 'first must be <= last' if @first > @last end |
Instance Attribute Details
#first ⇒ Object
Returns the value of attribute first.
5 6 7 |
# File 'lib/ipcat/iprange.rb', line 5 def first @first end |
#last ⇒ Object
Returns the value of attribute last.
5 6 7 |
# File 'lib/ipcat/iprange.rb', line 5 def last @last end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/ipcat/iprange.rb', line 5 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/ipcat/iprange.rb', line 5 def url @url end |
Instance Method Details
#<=>(obj) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ipcat/iprange.rb', line 15 def <=>(obj) case obj when Integer compare_with_integer(obj) when IPRange # Assume all IPRanges are non-overlapping first <=> obj.first end end |