Module: QuoVadis::IpMasking::ClassMethods
- Defined in:
- lib/quo_vadis/ip_masking.rb
Instance Method Summary collapse
-
#mask_ip(ip) ⇒ Object
Based on Google Analytics masking support.google.com/analytics/answer/2763052.
Instance Method Details
#mask_ip(ip) ⇒ Object
Based on Google Analytics masking support.google.com/analytics/answer/2763052
20 21 22 23 24 25 26 27 |
# File 'lib/quo_vadis/ip_masking.rb', line 20 def mask_ip(ip) addr = IPAddr.new ip if addr.ipv4? addr.mask(24).to_s # set last octet to 0 else addr.mask(48).to_s # set last 80 bits to 0 end end |