Class: Fauna::Bytes
- Inherits:
-
Object
- Object
- Fauna::Bytes
- Defined in:
- lib/fauna/objects.rb
Overview
A Bytes wrapper.
Reference: FaunaDB Special Types
Instance Attribute Summary collapse
-
#bytes ⇒ Object
The raw bytes.
Class Method Summary collapse
-
.from_base64(enc) ⇒ Object
Create new Bytes object from Base64 encoded bytes.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Returns
trueifotheris a Bytes and contains the same bytes. -
#initialize(bytes) ⇒ Bytes
constructor
Creates a new Bytes wrapper with the given parameters.
-
#to_hash ⇒ Object
Converts the Bytes to Hash form.
Constructor Details
#initialize(bytes) ⇒ Bytes
Creates a new Bytes wrapper with the given parameters.
bytes-
The bytes to be wrapped by the Bytes object.
Reference: FaunaDB Special Types
111 112 113 |
# File 'lib/fauna/objects.rb', line 111 def initialize(bytes) self.bytes = bytes end |
Instance Attribute Details
#bytes ⇒ Object
The raw bytes.
103 104 105 |
# File 'lib/fauna/objects.rb', line 103 def bytes @bytes end |
Class Method Details
.from_base64(enc) ⇒ Object
Create new Bytes object from Base64 encoded bytes.
129 130 131 |
# File 'lib/fauna/objects.rb', line 129 def self.from_base64(enc) new(Base64.urlsafe_decode64(enc)) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Returns true if other is a Bytes and contains the same bytes.
121 122 123 124 |
# File 'lib/fauna/objects.rb', line 121 def ==(other) return false unless other.is_a? Bytes bytes == other.bytes end |
#to_hash ⇒ Object
Converts the Bytes to Hash form.
116 117 118 |
# File 'lib/fauna/objects.rb', line 116 def to_hash { :@bytes => Base64.urlsafe_encode64(bytes) } end |