Class: Ftpd::FileInfo
- Inherits:
-
Object
- Object
- Ftpd::FileInfo
- Defined in:
- lib/ftpd/file_info.rb
Overview
Information about a file object (file, directory, symlink, etc.)
Instance Attribute Summary collapse
-
#ftype ⇒ String
readonly
One of: * ‘file’ * ‘directory’ * ‘characterSpecial’ * ‘blockSpecial’ * ‘fifo’ * ‘link’ * ‘socket’ * ‘unknown’.
-
#group ⇒ String
readonly
The group name.
-
#identifier ⇒ String
readonly
This uniquely identifies the file: Two objects with the same identifier are expected to refer to the same file or directory.
-
#mode ⇒ Integer
readonly
The bits are: * 0 - others have execute permission * 1 - others have write permission * 2 - others have read permission * 3 - group has execute permission * 4 - group has write permission * 5 - group has read permission * 6 - owner has execute permission * 7 - owner has write permission * 8 - owner has read permission * 9 - sticky bit * 10 - set-group-ID bit * 11 - set UID bit Other bits may be present; they are ignored.
-
#mtime ⇒ Time
readonly
The modification time.
-
#nlink ⇒ Integer
readonly
The number of hard links.
-
#owner ⇒ String
readonly
The owner name.
-
#path ⇒ String
readonly
The object’s path.
-
#size ⇒ Integer
readonly
The size, in bytes.
Instance Method Summary collapse
-
#directory? ⇒ Boolean
True if the object is a directory.
-
#file? ⇒ Boolean
True if the object is a file.
-
#initialize(opts) ⇒ FileInfo
constructor
Create a new instance.
Constructor Details
#initialize(opts) ⇒ FileInfo
Create a new instance. See the various attributes for argument details.
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ftpd/file_info.rb', line 91 def initialize(opts) @ftype = opts[:ftype] @group = opts[:group] @identifier = opts[:identifier] @mode = opts[:mode] @mtime = opts[:mtime] @nlink = opts[:nlink] @owner = opts[:owner] @path = opts[:path] @size = opts[:size] end |
Instance Attribute Details
#ftype ⇒ String (readonly)
One of:
-
‘file’
-
‘directory’
-
‘characterSpecial’
-
‘blockSpecial’
-
‘fifo’
-
‘link’
-
‘socket’
-
‘unknown’
20 21 22 |
# File 'lib/ftpd/file_info.rb', line 20 def ftype @ftype end |
#group ⇒ String (readonly)
Returns The group name.
24 25 26 |
# File 'lib/ftpd/file_info.rb', line 24 def group @group end |
#identifier ⇒ String (readonly)
This uniquely identifies the file: Two objects with the same identifier are expected to refer to the same file or directory.
On a disk file system, might be dev.inode, e.g. “8388621.48598”
This is optional and does not have to be set. If set, it is used in EPLF output.
75 76 77 |
# File 'lib/ftpd/file_info.rb', line 75 def identifier @identifier end |
#mode ⇒ Integer (readonly)
The bits are:
* 0 - others have execute permission
* 1 - others have write permission
* 2 - others have read permission
* 3 - group has execute permission
* 4 - group has write permission
* 5 - group has read permission
* 6 - owner has execute permission
* 7 - owner has write permission
* 8 - owner has read permission
* 9 - sticky bit
* 10 - set-group-ID bit
* 11 - set UID bit
Other bits may be present; they are ignored
42 43 44 |
# File 'lib/ftpd/file_info.rb', line 42 def mode @mode end |
#mtime ⇒ Time (readonly)
Returns The modification time.
46 47 48 |
# File 'lib/ftpd/file_info.rb', line 46 def mtime @mtime end |
#nlink ⇒ Integer (readonly)
Returns The number of hard links.
50 51 52 |
# File 'lib/ftpd/file_info.rb', line 50 def nlink @nlink end |
#owner ⇒ String (readonly)
Returns The owner name.
54 55 56 |
# File 'lib/ftpd/file_info.rb', line 54 def owner @owner end |
#path ⇒ String (readonly)
Returns The object’s path.
62 63 64 |
# File 'lib/ftpd/file_info.rb', line 62 def path @path end |
#size ⇒ Integer (readonly)
Returns The size, in bytes.
58 59 60 |
# File 'lib/ftpd/file_info.rb', line 58 def size @size end |
Instance Method Details
#directory? ⇒ Boolean
Returns true if the object is a directory.
111 112 113 |
# File 'lib/ftpd/file_info.rb', line 111 def directory? @ftype == 'directory' end |
#file? ⇒ Boolean
Returns true if the object is a file.
105 106 107 |
# File 'lib/ftpd/file_info.rb', line 105 def file? @ftype == 'file' end |