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