Class: NCMB::NFile
Constant Summary
Constants included
from NCMB
API_VERSION, DOMAIN, SCRIPT_API_VERSION, SCRIPT_DOMAIN
Instance Method Summary
collapse
Methods included from NCMB
CurrentUser, initialize
Methods inherited from Object
#ClassName, #[], #call, #convert_params, #deletable?, #delete, #error, #fields, #method_missing, #post, #put, #saved?, #set
Constructor Details
#initialize(file_path = nil) ⇒ NFile
7
8
9
10
11
12
13
14
|
# File 'lib/ncmb/file.rb', line 7
def initialize(file_path = nil)
@fields = {acl: NCMB::Acl.new, file: file_path}
if file_path
@fields[:fileName] = File.basename(file_path)
@fields['mime-type'.to_sym] = MIME::Types.type_for(file_path)[0]
end
@content = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class NCMB::Object
Instance Method Details
#base_path ⇒ Object
30
31
32
|
# File 'lib/ncmb/file.rb', line 30
def base_path
"/#{@@client.api_version}/files"
end
|
22
23
24
|
# File 'lib/ncmb/file.rb', line 22
def get
@content = @@client.get path
end
|
26
27
28
|
# File 'lib/ncmb/file.rb', line 26
def path
"#{base_path}/#{@fields[:fileName]}"
end
|
#save ⇒ Object
Also known as:
update
16
17
18
19
|
# File 'lib/ncmb/file.rb', line 16
def save
@fields[:file] = open(self.file)
super
end
|