Class: Ftpd::ListFormat::Ls

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

Overview

Directory formatter that approximates the output of “ls -l”

Defined Under Namespace

Classes: FileMode, FileType

Instance Method Summary collapse

Constructor Details

#initialize(file_info) ⇒ Ls

Create a new formatter for a file object

Parameters:



13
14
15
# File 'lib/ftpd/list_format/ls.rb', line 13

def initialize(file_info)
  @file_info = file_info
end

Instance Method Details

#to_sObject

Return the formatted directory entry, for example:

-rw-r--r-- 1 user     group    Mar  3 08:38 foo


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ftpd/list_format/ls.rb', line 20

def to_s
  '%s%s %d %-8s %-8s %8d %s %s' % [
    file_type,
    file_mode_letters,
    @file_info.nlink,
    @file_info.owner,
    @file_info.group,
    @file_info.size,
    format_time(@file_info.mtime),
    filename,
  ]
end