ruby - How to create IPAddr-object with a netmask -


i tried use ruby's ipaddr class , i've been wondering if possible create new ipaddr netmask. clarify issue i've done:

ipaddr.new "192.186.2.253/24" => #<ipaddr: ipv4:192.186.2.0/255.255.255.0> 

what expect this:

#<ipaddr: ipv4:192.186.2.253/255.255.255.0> 

if use to_range method, ip addresses matching second example.

did wrong class? how can achieve initialize such ip address without cutting off host id.

thanks lot

when netmask supplied, address treated network address, not host address, @ least that's how interpret findings in combination the docs:

if prefixlen or mask specified, returns masked ip address.

i assume, "masked ip address", author means network address, @ least that's makes sense given behavior observed , description of ipaddr#to_range method.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -