Class: Ftpd::ListFormat::Ls::FileType

Inherits:
Object
  • Object
show all
Defined in:
lib/ftpd/list_format/ls.rb

Overview

Map file type strings to ls file type letters

Class Method Summary collapse

Class Method Details

.letter(ftype) ⇒ String

Map a file type string to a file type letter.

Parameters:

  • ftype (String)

    file type as returned by File::Stat#ftype

Returns:

  • (String)

    File type letter


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ftpd/list_format/ls.rb', line 68

def self.letter(ftype)
  case ftype
  when 'file'
    '-'
  when 'directory'
    'd'
  when 'characterSpecial'
    'c'
  when 'blockSpecial'
    'b'
  when 'fifo'
    'p'
  when 'link'
    'l'
  when 'socket'
    's'
  else  # 'unknown', etc.
    '?'
  end
end