Class: WavesLib::WrappedBuffer

Inherits:
IO::Buffer
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/waves_lib/wrapped_buffer.rb

Overview

IO::Buffer + json utils

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_base64(str) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/waves_lib/wrapped_buffer.rb', line 18

def self.from_base64(str)
  bin = Base64.strict_decode64(str)
  buf = WrappedBuffer.new(bin.length)
  buf.set_string(bin)

  buf
end

Instance Method Details

#to_json(_) ⇒ Object



13
14
15
# File 'lib/waves_lib/wrapped_buffer.rb', line 13

def to_json(_)
  JSON.generate({ __type: "buffer", value: Base64.strict_encode64(get_string) })
end