Class: OnlinePayments::SDK::UploadableFile
- Inherits:
-
Object
- Object
- OnlinePayments::SDK::UploadableFile
- Defined in:
- lib/onlinepayments/sdk/uploadable_file.rb
Overview
A file that can be uploaded
The allowed forms of content are defined by the Connection implementation The default implementation supports file paths and IO objects.
Instance Attribute Summary collapse
-
#content ⇒ String, IO
readonly
The file’s content.
-
#content_length ⇒ Integer
readonly
The file’s content length, or -1 if not known.
-
#content_type ⇒ String
readonly
The file’s content type.
-
#file_name ⇒ String
readonly
The name of the file.
Instance Method Summary collapse
-
#initialize(file_name, content, content_type, content_length = -1)) ⇒ UploadableFile
constructor
A new instance of UploadableFile.
Constructor Details
#initialize(file_name, content, content_type, content_length = -1)) ⇒ UploadableFile
Returns a new instance of UploadableFile.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/onlinepayments/sdk/uploadable_file.rb', line 14 def initialize(file_name, content, content_type, content_length=-1) raise ArgumentError.new("file_name is required") if file_name.nil? or !file_name.strip raise ArgumentError.new("content is required") if content.nil? raise ArgumentError.new("content_type is required") if content_type.nil? or !content_type.strip @file_name = file_name @content = content @content_type = content_type @content_length = [content_length, -1].max end |
Instance Attribute Details
#content ⇒ String, IO (readonly)
The file’s content.
12 13 14 |
# File 'lib/onlinepayments/sdk/uploadable_file.rb', line 12 def content @content end |
#content_length ⇒ Integer (readonly)
The file’s content length, or -1 if not known.
12 13 14 |
# File 'lib/onlinepayments/sdk/uploadable_file.rb', line 12 def content_length @content_length end |
#content_type ⇒ String (readonly)
The file’s content type.
12 13 14 |
# File 'lib/onlinepayments/sdk/uploadable_file.rb', line 12 def content_type @content_type end |
#file_name ⇒ String (readonly)
The name of the file.
12 13 14 |
# File 'lib/onlinepayments/sdk/uploadable_file.rb', line 12 def file_name @file_name end |