Class: Parse::Bytes

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/datatypes.rb

Overview

Bytes


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Bytes

Returns a new instance of Bytes.



61
62
63
64
# File 'lib/parse/datatypes.rb', line 61

def initialize(data)
  bytes = data["base64"]
  @value = Base64.decode64(bytes)
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



59
60
61
# File 'lib/parse/datatypes.rb', line 59

def value
  @value
end

Instance Method Details

#to_json(*a) ⇒ Object



66
67
68
69
70
71
# File 'lib/parse/datatypes.rb', line 66

def to_json(*a)
  {
      Protocol::KEY_TYPE => Protocol::TYPE_BYTES,
      "base64" => Base64.encode64(@value)
  }.to_json(*a)
end