Class: Parse::File

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

Overview

File


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ File

Returns a new instance of File.



271
272
273
274
# File 'lib/parse/datatypes.rb', line 271

def initialize(data)
  @name = data["name"]
  @url = data["url"]
end

Instance Attribute Details

#nameObject

‘{“__type”:“File”, “name”:“profile.png”, “url”=>“”}’



268
269
270
# File 'lib/parse/datatypes.rb', line 268

def name
  @name
end

#urlObject

Returns the value of attribute url.



269
270
271
# File 'lib/parse/datatypes.rb', line 269

def url
  @url
end

Instance Method Details

#as_json(*a) ⇒ Object



287
288
289
290
291
292
293
# File 'lib/parse/datatypes.rb', line 287

def as_json(*a)
  {
      Protocol::KEY_TYPE => Protocol::TYPE_FILE,
      "name" => @name,
      "url" => @url
  }
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


276
277
278
279
# File 'lib/parse/datatypes.rb', line 276

def eql?(other)
  self.class.equal?(other.class) &&
    url == other.url
end

#hashObject



283
284
285
# File 'lib/parse/datatypes.rb', line 283

def hash
  url.hash
end

#to_json(*a) ⇒ Object



295
296
297
# File 'lib/parse/datatypes.rb', line 295

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