mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 11:32:24 -05:00
17 lines
204 B
Ruby
17 lines
204 B
Ruby
|
class IPAddr
|
||
|
|
||
|
def to_cidr_s
|
||
|
if @addr
|
||
|
mask = @mask_addr.to_s(2).count('1')
|
||
|
if mask == 32
|
||
|
to_s
|
||
|
else
|
||
|
"#{to_s}/#{mask}"
|
||
|
end
|
||
|
else
|
||
|
nil
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|