Class: CFA::Grub2::InstallDevice

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cfa/grub2/install_device.rb

Overview

Model representing configuration in file /etc/default/grub_installdevice

Constant Summary collapse

PATH =
"/etc/default/grub_installdevice"

Instance Method Summary collapse

Constructor Details

#initialize(file_handler: File) ⇒ InstallDevice

Returns a new instance of InstallDevice.



38
39
40
# File 'lib/cfa/grub2/install_device.rb', line 38

def initialize(file_handler: File)
  super(InstallDeviceParser, PATH, file_handler: file_handler)
end

Instance Method Details

#activate=(enabled) ⇒ Object

sets special entry activate



83
84
85
86
87
88
89
90
91
# File 'lib/cfa/grub2/install_device.rb', line 83

def activate=(enabled)
  if enabled
    return if activate?

    data << "activate"
  else
    data.delete("activate")
  end
end

#activate?Boolean

Ask if special entry for activate is there

Returns:

  • (Boolean)


78
79
80
# File 'lib/cfa/grub2/install_device.rb', line 78

def activate?
  data.include?("activate")
end

#add_device(dev) ⇒ Object

Adds new install device. Does nothing if it is already there.



43
44
45
# File 'lib/cfa/grub2/install_device.rb', line 43

def add_device(dev)
  data << dev unless data.include?(dev)
end

#devicesArray<String>

Returns non-special devices from configuration.

Returns:

  • (Array<String>)

    non-special devices from configuration



53
54
55
56
57
58
59
# File 'lib/cfa/grub2/install_device.rb', line 53

def devices
  res = data.dup
  res.delete("generic_mbr")
  res.delete("activate")

  res
end

#generic_mbr=(enabled) ⇒ Object

sets special entry generic_mbr



67
68
69
70
71
72
73
74
75
# File 'lib/cfa/grub2/install_device.rb', line 67

def generic_mbr=(enabled)
  if enabled
    return if generic_mbr?

    data << "generic_mbr"
  else
    data.delete("generic_mbr")
  end
end

#generic_mbr?Boolean

ask if special entry for generic_mbr is there

Returns:

  • (Boolean)


62
63
64
# File 'lib/cfa/grub2/install_device.rb', line 62

def generic_mbr?
  data.include?("generic_mbr")
end

#remove_device(dev) ⇒ Object

Removes install device. Does nothing if already not there.



48
49
50
# File 'lib/cfa/grub2/install_device.rb', line 48

def remove_device(dev)
  data.delete(dev)
end