Class: Aruba::Platforms::FilesystemStatus
- Inherits:
-
Object
- Object
- Aruba::Platforms::FilesystemStatus
- Defined in:
- lib/aruba/platforms/filesystem_status.rb
Overview
File System Status object
This is a wrapper for File::Stat returning only a subset of information.
Instance Method Summary collapse
- #atime ⇒ Object
- #ctime ⇒ Object
- #executable? ⇒ Boolean
-
#group ⇒ Object
Return owning group.
-
#initialize(path) ⇒ FilesystemStatus
constructor
A new instance of FilesystemStatus.
-
#mode ⇒ Object
Return permissions.
- #mtime ⇒ Object
-
#owner ⇒ Object
Return owner.
- #size ⇒ Object
-
#to_h ⇒ Hash
Convert status to hash.
Constructor Details
#initialize(path) ⇒ FilesystemStatus
Returns a new instance of FilesystemStatus.
33 34 35 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 33 def initialize(path) @status = File::Stat.new(path) end |
Instance Method Details
#atime ⇒ Object
21 22 23 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 21 def atime status.atime end |
#ctime ⇒ Object
17 18 19 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 17 def ctime status.ctime end |
#executable? ⇒ Boolean
13 14 15 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 13 def executable? status.executable? end |
#group ⇒ Object
Return owning group
48 49 50 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 48 def group status.gid end |
#mode ⇒ Object
Return permissions
38 39 40 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 38 def mode format("%o", status.mode)[-4, 4].gsub(/^0*/, "") end |
#mtime ⇒ Object
25 26 27 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 25 def mtime status.mtime end |
#owner ⇒ Object
Return owner
43 44 45 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 43 def owner status.uid end |
#size ⇒ Object
29 30 31 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 29 def size status.size end |
#to_h ⇒ Hash
Convert status to hash
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 56 def to_h { owner: owner, group: group, mode: mode, executable: executable?, ctime: ctime, atime: atime, mtime: mtime, size: size } end |