Class: CFA::Grub2::InstallDevice
- Inherits:
-
BaseModel
- Object
- BaseModel
- CFA::Grub2::InstallDevice
- 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
-
#activate=(enabled) ⇒ Object
sets special entry activate.
-
#activate? ⇒ Boolean
Ask if special entry for activate is there.
-
#add_device(dev) ⇒ Object
Adds new install device.
-
#devices ⇒ Array<String>
Non-special devices from configuration.
-
#generic_mbr=(enabled) ⇒ Object
sets special entry generic_mbr.
-
#generic_mbr? ⇒ Boolean
ask if special entry for generic_mbr is there.
-
#initialize(file_handler: nil) ⇒ InstallDevice
constructor
A new instance of InstallDevice.
-
#remove_device(dev) ⇒ Object
Removes install device.
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
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 |
#devices ⇒ Array<String>
Returns 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
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 |