Class: Couchbase::TranscoderFlags Private
- Inherits:
-
Object
- Object
- Couchbase::TranscoderFlags
- Defined in:
- lib/couchbase/transcoder_flags.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- FORMAT_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ reserved: 0, private: 1, json: 2, binary: 3, string: 4, }.freeze
- INV_FORMAT_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
FORMAT_MAP.invert.freeze
- COMPRESSION_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{none: 0}.freeze
- INV_COMPRESSION_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
COMPRESSION_MAP.invert
Instance Attribute Summary collapse
- #compression ⇒ Object readonly private
- #format ⇒ Object readonly private
- #lower_bits ⇒ Object readonly private
Class Method Summary collapse
- .decode(flags) ⇒ Object private
Instance Method Summary collapse
- #encode ⇒ Object private
-
#initialize(format:, compression: :none, lower_bits: 0) ⇒ TranscoderFlags
constructor
private
A new instance of TranscoderFlags.
Constructor Details
#initialize(format:, compression: :none, lower_bits: 0) ⇒ TranscoderFlags
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TranscoderFlags.
36 37 38 39 40 |
# File 'lib/couchbase/transcoder_flags.rb', line 36 def initialize(format:, compression: :none, lower_bits: 0) @format = format @compression = compression @lower_bits = lower_bits end |
Instance Attribute Details
#compression ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/couchbase/transcoder_flags.rb', line 33 def compression @compression end |
#format ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/couchbase/transcoder_flags.rb', line 32 def format @format end |
#lower_bits ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/couchbase/transcoder_flags.rb', line 34 def lower_bits @lower_bits end |
Class Method Details
.decode(flags) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/couchbase/transcoder_flags.rb', line 42 def self.decode(flags) return TranscoderFlags.new(format: flags) if flags.is_a?(Symbol) common_flags = flags >> 24 lower_bits = flags & 0x00ffff return TranscoderFlags.new(format: nil, lower_bits: lower_bits) if common_flags.zero? compression_bits = common_flags >> 5 format_bits = common_flags & 0x0f TranscoderFlags.new( format: INV_FORMAT_MAP[format_bits], compression: INV_COMPRESSION_MAP[compression_bits], lower_bits: lower_bits ) end |
Instance Method Details
#encode ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 |
# File 'lib/couchbase/transcoder_flags.rb', line 59 def encode common_flags = (COMPRESSION_MAP[@compression] << 5) | FORMAT_MAP[@format] (common_flags << 24) | @lower_bits end |