Class: Bootloader::DevicePath
- Inherits:
-
Object
- Object
- Bootloader::DevicePath
- Defined in:
- src/lib/bootloader/device_path.rb
Overview
Class for device path
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#exists? ⇒ Boolean
(also: #valid?)
True if the @path exists in the system.
-
#initialize(dev) ⇒ DevicePath
constructor
Performs initialization.
- #label? ⇒ Boolean
- #uuid? ⇒ Boolean
Constructor Details
#initialize(dev) ⇒ DevicePath
Performs initialization
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'src/lib/bootloader/device_path.rb', line 20 def initialize(dev) dev = dev.strip @path = if dev_by_uuid?(dev) # if defined by uuid, convert it dev.sub(/UUID="([-a-zA-Z0-9]*)"/, '/dev/disk/by-uuid/\1') elsif dev_by_label?(dev) # as well for label dev.sub(/LABEL="(.*)"/, '/dev/disk/by-label/\1') else # add it exactly (but whitespaces) as specified by the user dev end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'src/lib/bootloader/device_path.rb', line 15 def path @path end |
Instance Method Details
#exists? ⇒ Boolean Also known as: valid?
Returns true if the @path exists in the system.
36 37 38 |
# File 'src/lib/bootloader/device_path.rb', line 36 def exists? !devicegraph.find_by_any_name(path).nil? end |
#label? ⇒ Boolean
46 47 48 |
# File 'src/lib/bootloader/device_path.rb', line 46 def label? !!(path =~ /by-label/) end |
#uuid? ⇒ Boolean
42 43 44 |
# File 'src/lib/bootloader/device_path.rb', line 42 def uuid? !!(path =~ /by-uuid/) end |