Class: Pkgpurge::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/pkgpurge/entry.rb

Constant Summary collapse

S_IFMT =

See ‘/usr/includde/sys/_types/_s_ifmt.h`

0170000
S_IFDIR =
0040000
S_IFLNK =
0120000

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mode, uid, gid, size, checksum, mtime) ⇒ Entry

Returns a new instance of Entry.



19
20
21
22
23
24
25
26
27
28
# File 'lib/pkgpurge/entry.rb', line 19

def initialize(name, mode, uid, gid, size, checksum, mtime)
  @name = name
  @mode = mode
  @uid = uid
  @gid = gid
  @size = size
  @checksum = checksum
  @mtime = mtime
  @entries = {}
end

Instance Attribute Details

#checksumObject (readonly)

Returns the value of attribute checksum.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def checksum
  @checksum
end

#entriesObject (readonly)

Returns the value of attribute entries.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def entries
  @entries
end

#gidObject (readonly)

Returns the value of attribute gid.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def gid
  @gid
end

#modeObject (readonly)

Returns the value of attribute mode.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def mode
  @mode
end

#mtimeObject (readonly)

Returns the value of attribute mtime.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def mtime
  @mtime
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def size
  @size
end

#uidObject (readonly)

Returns the value of attribute uid.



17
18
19
# File 'lib/pkgpurge/entry.rb', line 17

def uid
  @uid
end

Class Method Details

.traverse_entry_with_path(entry, parent_path = nil) {|entry, File.expand_path(path)| ... } ⇒ Object

Yields:

  • (entry, File.expand_path(path))


3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pkgpurge/entry.rb', line 3

def self.traverse_entry_with_path(entry, parent_path = nil, &block)
  if parent_path
    path = File.join(parent_path, entry.name)
  else
    path = entry.name
  end

  yield(entry, File.expand_path(path))

  entry.entries.each do |_, entry|
    traverse_entry_with_path(entry, path, &block)
  end
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/pkgpurge/entry.rb', line 35

def directory?
  (@mode & S_IFMT) == S_IFDIR
end

#symlink?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/pkgpurge/entry.rb', line 39

def symlink?
  (@mode & S_IFMT) == S_IFLNK
end