Kanrisuru

Fstab::Options

The Kanrisuru::Remote::Fstab::Options class manages the mount options for the different file system types in the fstab.

Public Class Methods

new

Creates a new options instance. Requires a file system type and a set of options to validate and prepare. Options can either be a hash or a string.

options = Kanrisuru::Remote::Fstab::Options.new('nfs', soft: true, bg: true, nolock: true, port: 33333)
options.to_s
'soft,bg,nolock,port=33333'

options = Kanrisuru::Remote::Fstab::Options.new('smbfs', 'username=kanrisuru,password=123456,port=445,rw')
options.to_h
{
  "username" => "kanrisuru",
  "password" => "123456",
      "port" => "445",
        "rw" => true
}

option_exists?

Returns true if the option exists in the fs_mount_opts hash. This keeps track of all the available options for the different file system types. An optional type argument can be passed to check for a specified file system type.

Kanrisuru::Remote::Fstab::Options.option_exists?('owner')
true

Kanrisuru::Remote::Fstab::Options.option_exists?('uid', 'ntfs')
true

valid_option?

Returns true if the value for the option type is a valid type. Each option for a file system type is either a boolean flag or value based argument. An optional type argument can be passed to check for a specified file system type.

Kanrisuru::Remote::Fstab::Options.valid_option?('soft', true, 'nfs')
true

Kanrisuru::Remote::Fstab::Options.valid_option?('remount', true)
true

Public Instance Methods

[]

Get the parsed option.

options = Kanrisuru::Remote::Fstab::Options.new('smbfs', 'username=kanrisuru,password=123456,port=445,rw')
options['username']
'kanrisuru'

[]=

Set an option.

options = Kanrisuru::Remote::Fstab::Options.new('ext4', 'async,dev,group,owner,remount')
options['quota'] = true
options.to_h
{
    "async" => true,
      "dev" => true,
    "group" => true,
    "owner" => true,
  "remount" => true,
    "quota" => true
}

to_s

Output the options instance as a string that would be used with the mount or fstab file.

options = Kanrisuru::Remote::Fstab::Options.new('ext4', async: true, dev: true, group: true, owner: true, remount: true)
options.to_s
'async,dev,group,owner,remount'

to_h

Output the options instance as a hash.