Class: Carrierwave::Base64::Base64StringIO
- Inherits:
-
StringIO
- Object
- StringIO
- Carrierwave::Base64::Base64StringIO
- Defined in:
- lib/carrierwave/base64/base64_string_io.rb
Instance Attribute Summary collapse
-
#file_extension ⇒ Object
Returns the value of attribute file_extension.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Instance Method Summary collapse
-
#initialize(encoded_file, file_name) ⇒ Base64StringIO
constructor
A new instance of Base64StringIO.
- #original_filename ⇒ Object
Constructor Details
#initialize(encoded_file, file_name) ⇒ Base64StringIO
Returns a new instance of Base64StringIO.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/carrierwave/base64/base64_string_io.rb', line 6 def initialize(encoded_file, file_name) description, encoded_bytes = encoded_file.split(',') raise ArgumentError unless encoded_bytes raise ArgumentError if encoded_bytes.eql?('(null)') @file_name = file_name @file_extension = get_file_extension description bytes = ::Base64.decode64 encoded_bytes super bytes end |
Instance Attribute Details
#file_extension ⇒ Object
Returns the value of attribute file_extension.
4 5 6 |
# File 'lib/carrierwave/base64/base64_string_io.rb', line 4 def file_extension @file_extension end |
#file_name ⇒ Object
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/carrierwave/base64/base64_string_io.rb', line 4 def file_name @file_name end |
Instance Method Details
#original_filename ⇒ Object
19 20 21 |
# File 'lib/carrierwave/base64/base64_string_io.rb', line 19 def original_filename File.basename("#{@file_name}.#{@file_extension}") end |