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.



69
70
71
72
# File 'lib/parse/datatypes.rb', line 69

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

Instance Attribute Details

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#as_json(*a) ⇒ Object



74
75
76
77
78
79
# File 'lib/parse/datatypes.rb', line 74

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

#to_json(*a) ⇒ Object



81
82
83
# File 'lib/parse/datatypes.rb', line 81

def to_json(*a)
    as_json.to_json(*a)
end