class Fauna::Bytes

A Bytes wrapper.

Reference: FaunaDB Special Types

Attributes

bytes[RW]

The raw bytes.

Public Class Methods

from_base64(enc) click to toggle source

Create new Bytes object from Base64 encoded bytes.

# File lib/fauna/objects.rb, line 129
def self.from_base64(enc)
  new(Base64.urlsafe_decode64(enc))
end
new(bytes) click to toggle source

Creates a new Bytes wrapper with the given parameters.

bytes

The bytes to be wrapped by the Bytes object.

Reference: FaunaDB Special Types

# File lib/fauna/objects.rb, line 111
def initialize(bytes)
  self.bytes = bytes
end

Public Instance Methods

==(other) click to toggle source

Returns true if other is a Bytes and contains the same bytes.

# File lib/fauna/objects.rb, line 121
def ==(other)
  return false unless other.is_a? Bytes
  bytes == other.bytes
end
Also aliased as: eql?
eql?(other)
Alias for: ==
to_hash() click to toggle source

Converts the Bytes to Hash form.

# File lib/fauna/objects.rb, line 116
def to_hash
  { :@bytes => Base64.urlsafe_encode64(bytes) }
end