Class: Aruba::Platforms::FilesystemStatus
- Inherits:
-
Object
- Object
- Aruba::Platforms::FilesystemStatus
- Extended by:
- Forwardable
- 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.
Constant Summary collapse
- METHODS =
[ :executable?, :ctime, :atime, :mtime, :size ].freeze
Instance Method Summary collapse
-
#group ⇒ Object
Return owning group.
-
#initialize(path) ⇒ FilesystemStatus
constructor
A new instance of FilesystemStatus.
-
#mode ⇒ Object
Return permissions.
-
#owner ⇒ Object
Return owner.
-
#to_h ⇒ Hash
Convert status to hash.
Constructor Details
#initialize(path) ⇒ FilesystemStatus
Returns a new instance of FilesystemStatus.
27 28 29 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 27 def initialize(path) @status = File::Stat.new(path) end |
Instance Method Details
#group ⇒ Object
Return owning group
42 43 44 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 42 def group status.gid end |
#mode ⇒ Object
Return permissions
32 33 34 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 32 def mode format('%o', status.mode)[-4, 4].gsub(/^0*/, '') end |
#owner ⇒ Object
Return owner
37 38 39 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 37 def owner status.uid end |
#to_h ⇒ Hash
Convert status to hash
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 50 def to_h { owner: owner, group: group, mode: mode, executable: executable?, ctime: ctime, atime: atime, mtime: mtime, size: size } end |