LoginSignup
11
11

More than 5 years have passed since last update.

rubyで該当するIPアドレスが含まれているか比較する方法

Last updated at Posted at 2015-05-08
require 'ipaddr'
ipaddr = IPAddr.new("192.168.1.0/24")
ipaddr.include? "192.168.1.1" #=> true
ipaddr.include? "192.168.2.1" #=> false

参考: http://docs.ruby-lang.org/ja/1.9.3/class/IPAddr.html

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11