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.



33
34
35
# File 'lib/aruba/platforms/filesystem_status.rb', line 33

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

Instance Method Details

#atimeObject



21
22
23
# File 'lib/aruba/platforms/filesystem_status.rb', line 21

def atime
  status.atime
end

#ctimeObject



17
18
19
# File 'lib/aruba/platforms/filesystem_status.rb', line 17

def ctime
  status.ctime
end

#executable?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/aruba/platforms/filesystem_status.rb', line 13

def executable?
  status.executable?
end

#groupObject

Return owning group



48
49
50
# File 'lib/aruba/platforms/filesystem_status.rb', line 48

def group
  status.gid
end

#modeObject

Return permissions



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

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

#mtimeObject



25
26
27
# File 'lib/aruba/platforms/filesystem_status.rb', line 25

def mtime
  status.mtime
end

#ownerObject

Return owner



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

def owner
  status.uid
end

#sizeObject



29
30
31
# File 'lib/aruba/platforms/filesystem_status.rb', line 29

def size
  status.size
end

#to_hHash

Convert status to hash

Returns:

  • (Hash)

    A hash of values



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

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