Sha256: 8d0be9e236fa751bde047c8760f137e7b3e95f4cd8b617bb32ed7d7f1f247454
Contents?: true
Size: 594 Bytes
Versions: 3
Compression:
Stored size: 594 Bytes
Contents
# -*- ruby -*- # frozen_string_literal: true require 'ipaddr' module YSQL module TextEncoder class Inet < SimpleEncoder def encode(value) case value when IPAddr default_prefix = (value.family == Socket::AF_INET ? 32 : 128) s = value.to_s if value.respond_to?(:prefix) prefix = value.prefix else range = value.to_range prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i end s << "/" << prefix.to_s if prefix != default_prefix s else value end end end end end # module PG
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yugabytedb-ysql-0.5 | lib/ysql/text_encoder/inet.rb |
yugabytedb-ysql-0.4 | lib/ysql/text_encoder/inet.rb |
yugabytedb-ysql-0.3 | lib/pg/text_encoder/inet.rb |