Class: Sys::Mount

Inherits:
Object show all
Defined in:
lib/epitools/sys/mounts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Mount

Returns a new instance of Mount


18
19
20
21
# File 'lib/epitools/sys/mounts.rb', line 18

def initialize(line)
  @path, @dev, @type, @options = line.strip.split(' ')
  @options = @options.split(",")
end

Instance Attribute Details

#devObject

Returns the value of attribute dev


16
17
18
# File 'lib/epitools/sys/mounts.rb', line 16

def dev
  @dev
end

#optionsObject

Returns the value of attribute options


16
17
18
# File 'lib/epitools/sys/mounts.rb', line 16

def options
  @options
end

#typeObject

Returns the value of attribute type


16
17
18
# File 'lib/epitools/sys/mounts.rb', line 16

def type
  @type
end

Instance Method Details

#dirnameObject


40
41
42
# File 'lib/epitools/sys/mounts.rb', line 40

def dirname
  path.dirs.last
end

#inspectObject


27
28
29
# File 'lib/epitools/sys/mounts.rb', line 27

def inspect
  "#{type}: #{path} (#{dev})"
end

#pathObject


35
36
37
38
# File 'lib/epitools/sys/mounts.rb', line 35

def path
  # Unescape findmnt's hex codes
  Path.new "#{eval %{"#{@path}"}}/"
end

#system?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/epitools/sys/mounts.rb', line 23

def system?
  (path =~ %r{^/(sys|dev|proc|run/user|tmp)}) or dev == "systemd-1"
end

#to_sObject


31
32
33
# File 'lib/epitools/sys/mounts.rb', line 31

def to_s
  "#{path} (#{dev})"
end