Class: S3FileHandler::CSV::Create
- Inherits:
-
BaseOperation
- Object
- BaseOperation
- S3FileHandler::CSV::Create
- Defined in:
- lib/s3_file_handler/csv/create.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#file_key ⇒ Object
readonly
Returns the value of attribute file_key.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Attributes inherited from BaseOperation
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(bucket_name, file_key, headers:, client: S3FileHandler.client) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(bucket_name, file_key, headers:, client: S3FileHandler.client) ⇒ Create
Returns a new instance of Create.
10 11 12 13 14 15 16 |
# File 'lib/s3_file_handler/csv/create.rb', line 10 def initialize(bucket_name, file_key, headers:, client: S3FileHandler.client) super(client: client) @bucket_name = bucket_name @file_key = file_key @headers = headers end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/s3_file_handler/csv/create.rb', line 8 def bucket_name @bucket_name end |
#file_key ⇒ Object (readonly)
Returns the value of attribute file_key.
8 9 10 |
# File 'lib/s3_file_handler/csv/create.rb', line 8 def file_key @file_key end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/s3_file_handler/csv/create.rb', line 8 def headers @headers end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/s3_file_handler/csv/create.rb', line 18 def execute csv_string = ::CSV.generate do |csv| csv << headers end S3FileHandler.upload_file(bucket_name, file_key, content: csv_string) end |