Class: Worldline::Acquiring::SDK::Domain::UploadableFile
- Inherits:
-
Object
- Object
- Worldline::Acquiring::SDK::Domain::UploadableFile
- Defined in:
- lib/worldline/acquiring/sdk/domain/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.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 16 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.
14 15 16 |
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14 def content @content end |
#content_length ⇒ Integer (readonly)
The file’s content length, or -1 if not known.
14 15 16 |
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14 def content_length @content_length end |
#content_type ⇒ String (readonly)
The file’s content type.
14 15 16 |
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14 def content_type @content_type end |
#file_name ⇒ String (readonly)
The name of the file.
14 15 16 |
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14 def file_name @file_name end |