Class: Arrow::PathExtension

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow/path-extension.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathExtension

Returns a new instance of PathExtension.



20
21
22
# File 'lib/arrow/path-extension.rb', line 20

def initialize(path)
  @path = path
end

Instance Method Details

#extractObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/arrow/path-extension.rb', line 24

def extract
  basename = ::File.basename(@path)
  components = basename.split(".")
  return {} if components.size < 2

  extension = components.last.downcase
  if components.size > 2
    compression = CompressionType.resolve_extension(extension)
    if compression
      {
        format: components[-2].downcase,
        compression: compression,
      }
    else
      {format: extension}
    end
  else
    {format: extension}
  end
end