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.
31 32 33 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 31 def initialize(path) @status = File::Stat.new(path) end |
Instance Method Details
#group ⇒ Object
Return owning group
46 47 48 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 46 def group status.gid end |
#mode ⇒ Object
Return permissions
36 37 38 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 36 def mode format("%o", status.mode)[-4,4].gsub(/^0*/, '') end |
#owner ⇒ Object
Return owner
41 42 43 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 41 def owner status.uid end |
#to_h ⇒ Hash
Convert status to hash
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aruba/platforms/filesystem_status.rb', line 54 def to_h { :owner => owner, :group => group, :mode => mode, :executable => executable?, :ctime => ctime, :atime => atime, :mtime => mtime, :size => size } end |