Class: Kinu::HttpClient::UploadFile
- Inherits:
-
Object
- Object
- Kinu::HttpClient::UploadFile
show all
- Defined in:
- lib/kinu/http_client.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of UploadFile.
53
54
55
|
# File 'lib/kinu/http_client.rb', line 53
def initialize(file)
@file = file
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
78
79
80
|
# File 'lib/kinu/http_client.rb', line 78
def method_missing(*args)
io.send(*args)
end
|
Instance Method Details
#content_type ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/kinu/http_client.rb', line 57
def content_type
case File.extname(@file.path)
when '.jpg', '.jpeg'
'image/jpeg'
when '.png'
'image/png'
when '.gif'
'image/gif'
else
'application/octet-stream'
end
end
|
#io ⇒ Object
82
83
84
|
# File 'lib/kinu/http_client.rb', line 82
def io
@io ||= Faraday::UploadIO.new(@file, content_type, original_filename)
end
|
#original_filename ⇒ Object
70
71
72
|
# File 'lib/kinu/http_client.rb', line 70
def original_filename
File.basename(@file.path)
end
|
#respond_to?(name, include_all = false) ⇒ Boolean
74
75
76
|
# File 'lib/kinu/http_client.rb', line 74
def respond_to?(name, include_all = false)
io.respond_to?(name, include_all)
end
|