Class: Aruba::Platforms::FilesystemStatus

Inherits:
Object
  • Object
show all
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

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

#groupObject

Return owning group


42
43
44
# File 'lib/aruba/platforms/filesystem_status.rb', line 42

def group
  status.gid
end

#modeObject

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

#ownerObject

Return owner


37
38
39
# File 'lib/aruba/platforms/filesystem_status.rb', line 37

def owner
  status.uid
end

#to_hHash

Convert status to hash

Returns:

  • (Hash)

    A hash of values


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