class Parse::File
tf = Parse::File.new
(:body => “Hello World!”, :local_filename => “hello.txt”) tf.save
Attributes
body[RW]
content_type[RW]
local_filename[RW]
‘{“avatar”: {“__type”:“File”, “name”:“profile.png”, “url”=>“”}}’
parse_filename[RW]
url[RW]
Public Class Methods
new(data)
click to toggle source
# File lib/parse/datatypes.rb, line 307 def initialize(data) data = Hash[data.map{ |k, v| [k.to_s, v] }] # convert hash keys to strings @local_filename = data["local_filename"] if data["local_filename"] @parse_filename = data["name"] if data["name"] @parse_filename = data["parse_filename"] if data["parse_filename"] @content_type = data["content_type"] if data["content_type"] @url = data["url"] if data["url"] @body = data["body"] if data["body"] end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/parse/datatypes.rb, line 317 def eql?(other) self.class.equal?(other.class) && url == other.url end
Also aliased as: ==
hash()
click to toggle source
# File lib/parse/datatypes.rb, line 324 def hash url.hash end
save()
click to toggle source
# File lib/parse/datatypes.rb, line 328 def save uri = Parse::Protocol.file_uri(@local_filename) resp = Parse.client.request(uri, :post, @body, nil, @content_type) @parse_filename = resp["name"] @url = resp["url"] resp end
to_h(*a)
click to toggle source
# File lib/parse/datatypes.rb, line 336 def to_h(*a) { Protocol::KEY_TYPE => Protocol::TYPE_FILE, "name" => @parse_filename, "url" => @url } end
Also aliased as: as_json
to_json(*a)
click to toggle source
# File lib/parse/datatypes.rb, line 345 def to_json(*a) to_h.to_json(*a) end