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: nil) ⇒ InstallDevice

Returns a new instance of InstallDevice.



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

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

Instance Method Details

#activate=(enabled) ⇒ Object

sets special entry activate



88
89
90
91
92
93
94
95
96
# File 'lib/cfa/grub2/install_device.rb', line 88

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)


83
84
85
# File 'lib/cfa/grub2/install_device.rb', line 83

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

#add_device(dev) ⇒ Object

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



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

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



58
59
60
61
62
63
64
# File 'lib/cfa/grub2/install_device.rb', line 58

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

  res
end

#generic_mbr=(enabled) ⇒ Object

sets special entry generic_mbr



72
73
74
75
76
77
78
79
80
# File 'lib/cfa/grub2/install_device.rb', line 72

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)


67
68
69
# File 'lib/cfa/grub2/install_device.rb', line 67

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

#remove_device(dev) ⇒ Object

Removes install device. Does nothing if already not there.



53
54
55
# File 'lib/cfa/grub2/install_device.rb', line 53

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