Class: ForestLiana::Base64StringIO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/forest_liana/base64_string_io.rb

Defined Under Namespace

Classes: ArgumentError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(encoded_file) ⇒ Base64StringIO

Returns a new instance of Base64StringIO.

Raises:


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_formatObject

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_filenameObject


19
20
21
# File 'lib/forest_liana/base64_string_io.rb', line 19

def original_filename
  File.basename("file.#{@file_format}")
end