Method: NetAddr::IPv4#initialize
- Defined in:
- lib/ipv4.rb
#initialize(i) ⇒ IPv4
Create an IPv4 from an Integer. Must be between 0 and 2**32-1. Throws ValidationError on error.
10 11 12 13 14 15 16 17 |
# File 'lib/ipv4.rb', line 10 def initialize(i) if (!i.kind_of?(Integer)) raise ValidationError, "Expected an Integer for 'i' but got a #{i.class}." elsif ( (i < 0) || (i > 2**32-1) ) raise ValidationError, "#{i} is out of bounds for IPv4." end @addr = i end |