Module: Utilities::Files

Defined in:
lib/utilities/files.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) lines_per_file(files)

Parameters:

  • files (Array)


4
5
6
7
8
9
# File 'lib/utilities/files.rb', line 4

def self.lines_per_file(files)
  puts 'Lines per file: '
  files.each do |f|
    puts `wc -l #{f}`
  end
end

+ (Array [Boolean, String]) recognized_batch_file_type?(file)

Parameters:

  • file (String)

Returns:

  • (Array [Boolean, String])


13
14
15
16
17
18
19
20
21
# File 'lib/utilities/files.rb', line 13

def self.recognized_batch_file_type?(file)
  mimetype = `file -b "#{file.path}"`.gsub(/\n/, '')
  case mimetype
  when /utf-8/i, /ascii/i, /bibtex/i
    return [true, mimetype]
  else
    return [false, mimetype]
  end
end