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.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ftpd/file_info.rb', line 89 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’
18 19 20 |
# File 'lib/ftpd/file_info.rb', line 18 def ftype @ftype end |
#group ⇒ String (readonly)
Returns The group name.
22 23 24 |
# File 'lib/ftpd/file_info.rb', line 22 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.
73 74 75 |
# File 'lib/ftpd/file_info.rb', line 73 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
40 41 42 |
# File 'lib/ftpd/file_info.rb', line 40 def mode @mode end |
#mtime ⇒ Time (readonly)
Returns The modification time.
44 45 46 |
# File 'lib/ftpd/file_info.rb', line 44 def mtime @mtime end |
#nlink ⇒ Integer (readonly)
Returns The number of hard links.
48 49 50 |
# File 'lib/ftpd/file_info.rb', line 48 def nlink @nlink end |
#owner ⇒ String (readonly)
Returns The owner name.
52 53 54 |
# File 'lib/ftpd/file_info.rb', line 52 def owner @owner end |
#path ⇒ String (readonly)
Returns The object’s path.
60 61 62 |
# File 'lib/ftpd/file_info.rb', line 60 def path @path end |
#size ⇒ Integer (readonly)
Returns The size, in bytes.
56 57 58 |
# File 'lib/ftpd/file_info.rb', line 56 def size @size end |
Instance Method Details
#directory? ⇒ Boolean
Returns true if the object is a directory.
109 110 111 |
# File 'lib/ftpd/file_info.rb', line 109 def directory? @ftype == 'directory' end |
#file? ⇒ Boolean
Returns true if the object is a file.
103 104 105 |
# File 'lib/ftpd/file_info.rb', line 103 def file? @ftype == 'file' end |