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".freeze

Instance Method Summary collapse

Constructor Details

#initialize(file_handler: nil) ⇒ InstallDevice

Returns a new instance of InstallDevice.



41
42
43
# File 'lib/cfa/grub2/install_device.rb', line 41

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

Instance Method Details

#activate=(enabled) ⇒ Object

sets special entry activate



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

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)


81
82
83
# File 'lib/cfa/grub2/install_device.rb', line 81

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

#add_device(dev) ⇒ Object

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



46
47
48
# File 'lib/cfa/grub2/install_device.rb', line 46

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



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

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

  res
end

#generic_mbr=(enabled) ⇒ Object

sets special entry generic_mbr



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

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)


65
66
67
# File 'lib/cfa/grub2/install_device.rb', line 65

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

#remove_device(dev) ⇒ Object

Removes install device. Does nothing if already not there.



51
52
53
# File 'lib/cfa/grub2/install_device.rb', line 51

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