Module: IpHelper

Extended by:
IpHelper
Included in:
IpHelper
Defined in:
lib/rails_com/utils/ip_helper.rb

Overview

Instance Method Summary collapse

Instance Method Details

#read(name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rails_com/utils/ip_helper.rb', line 8

def read(name)
  IO.foreach(name) do |x|
    if x.match? /apnic\|CN\|ipv4/
      r = x.split('|').values_at(3, 4)
      int_min = IPAddr.new(r[0]).to_i
      int_max = min + r[1].to_i - 1
      ip_max = IPAddr.new(max, Socket::AF_INET).to_s

      [r[0], ip_max, int_min, int_max]
    end
  end
end