Class: HrrRbLxns::Files::File

Inherits:
Object
  • Object
show all
Defined in:
lib/hrr_rb_lxns/files/file.rb

Overview

A class that takes a path to a namespace file and collects then keeps its inode.

Examples:

file = HrrRbLxns::Files::File.new "/proc/12345/ns/uts"
file.path # => "/proc/12345/ns/uts"
file.ino  # => 4026531839

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ File

Returns a new instance of File.

Parameters:

  • path (String) —

    The path to a namespace file.



27
28
29
30
# File 'lib/hrr_rb_lxns/files/file.rb', line 27

def initialize path
  @path = path
  @ino  = ::File.exist?(path) ? ::File.stat(path).ino : nil
end

Instance Attribute Details

#ino ⇒ Integer? (readonly)

Returns the file information of attribute :ino.

Returns:

  • (Integer, nil) —

    The inode number of the namespace file. If the path is not valid, then ino is nil.



23
24
25
# File 'lib/hrr_rb_lxns/files/file.rb', line 23

def ino
  @ino
end

#path ⇒ String (readonly)

Returns the file information of attribute :path.

Returns:

  • (String) —

    The path to the namespace file.



17
18
19
# File 'lib/hrr_rb_lxns/files/file.rb', line 17

def path
  @path
end