mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 14:43:38 +08: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
|