Class: CassandraCQL::Utility

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra-cql/utility.rb

Class Method Summary collapse

Class Method Details

.binary_data?(string) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/cassandra-cql/utility.rb', line 29

def self.binary_data?(string)
  if RUBY_VERSION >= "1.9"
    string.encoding.name == "ASCII-8BIT"
  else
    string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.size) > 0.3 || string.index("\x00") unless string.empty?
  end
end

.compress(source, level = 2) ⇒ Object



21
22
23
# File 'lib/cassandra-cql/utility.rb', line 21

def self.compress(source, level=2)
  Zlib::Deflate.deflate(source, level)
end

.decompress(source) ⇒ Object



25
26
27
# File 'lib/cassandra-cql/utility.rb', line 25

def self.decompress(source)
  Zlib::Inflate.inflate(source)
end