Class: Aruba::Platforms::FilesystemStatus

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

Constructor Details

#initialize(path) ⇒ FilesystemStatus

Returns a new instance of FilesystemStatus.



35
36
37
# File 'lib/aruba/platforms/filesystem_status.rb', line 35

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

Instance Method Details

#atimeObject



23
24
25
# File 'lib/aruba/platforms/filesystem_status.rb', line 23

def atime
  status.atime
end

#ctimeObject



19
20
21
# File 'lib/aruba/platforms/filesystem_status.rb', line 19

def ctime
  status.ctime
end

#executable?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/aruba/platforms/filesystem_status.rb', line 15

def executable?
  status.executable?
end

#groupObject

Return owning group



50
51
52
# File 'lib/aruba/platforms/filesystem_status.rb', line 50

def group
  status.gid
end

#modeObject

Return permissions



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

def mode
  format('%o', status.mode)[-4, 4].gsub(/^0*/, '')
end

#mtimeObject



27
28
29
# File 'lib/aruba/platforms/filesystem_status.rb', line 27

def mtime
  status.mtime
end

#ownerObject

Return owner



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

def owner
  status.uid
end

#sizeObject



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

def size
  status.size
end

#to_hHash

Convert status to hash

Returns:

  • (Hash)

    A hash of values



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/aruba/platforms/filesystem_status.rb', line 58

def to_h
  {
    owner: owner,
    group: group,
    mode: mode,
    executable: executable?,
    ctime: ctime,
    atime: atime,
    mtime: mtime,
    size: size
  }
end