Class: CheckFile

Inherits:
Object
  • Object
show all
Defined in:
lib/check_file.rb

Instance Method Summary collapse

Instance Method Details

#check_file?(file) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/check_file.rb', line 12

def check_file?(file)
  check_path?(file.path)
end

#check_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
9
10
# File 'lib/check_file.rb', line 2

def check_path?(path)
  accepted_formats = [".xls"]
  unless File.file?(path)
    raise 'File does not exist'
  end
  unless accepted_formats.include? File.extname(path)
    raise 'Not accepted format: ' + File.extname(path)
  end
end