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.



31
32
33
# File 'lib/aruba/platforms/filesystem_status.rb', line 31

def initialize(path)
  @status = File::Stat.new(path)
end

Instance Method Details

#groupObject

Return owning group



46
47
48
# File 'lib/aruba/platforms/filesystem_status.rb', line 46

def group
  status.gid
end

#modeObject

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

#ownerObject

Return owner



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

def owner
  status.uid
end

#to_hHash

Convert status to hash

Returns:

  • (Hash)

    A hash of values



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