Class: Oct::FileStat

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

Instance Method Summary collapse

Instance Method Details

#mode(files, options = {}) ⇒ Object

print octal file listing

Parameters:

  • files (Array)

    files to be listed



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/oct/oct.rb', line 8

def mode(files, options={})
  puts "oct mode files: #{files.inspect}".cyan if options[:verbose]
  files.sort.each do |file|
    stat = File.stat(file)
    printf("%04o ", stat.mode & 07777)
    if stat.directory?
      puts file.blue
    elsif stat.executable?
      puts file.green
    elsif stat.symlink?
      puts file.cyan
    else
      puts file
    end
  end
end