class IPAddr
TODO: we probably shouldn’t do go around monkey-patching like this.
Public Instance Methods
as_json(options = {})
click to toggle source
# File lib/pg_funcall/ipaddr_monkeys.rb, line 19 def as_json(options = {}) if (ipv6? && prefixlen == 64) || (ipv4? && prefixlen == 32) to_s else to_cidr_string end end
prefixlen()
click to toggle source
# File lib/pg_funcall/ipaddr_monkeys.rb, line 8 def prefixlen mask = @mask_addr len = 0 len += mask & 1 and mask >>= 1 until mask == 0 len end
to_cidr_string()
click to toggle source
# File lib/pg_funcall/ipaddr_monkeys.rb, line 15 def to_cidr_string "#{to_s}/#{prefixlen}" end