Class: Diskman::RootDevice
Instance Attribute Summary
Attributes inherited from Device
#name, #path
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Device
#get_clone_command, #get_fdisk_command, #get_mkfs_command, #get_write_command, #initialize
Class Method Details
.choose ⇒ Object
13
14
15
16
17
|
# File 'lib/diskman/root_device.rb', line 13
def self.choose
selection = Chooser.new(RootDevice.get_removable, item: 'removable device').select
selection.ensure_not_mounted!
selection
end
|
.get_removable ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/diskman/root_device.rb', line 3
def self.get_removable
Dir['/sys/block/*/removable'].select do |file|
File.read(file).strip == '1'
end.map do |path|
path =~ %r[^/sys/block/(.*)/removable$]x && RootDevice.new($1)
end.reject do |device|
device.name =~ /sr\d+/
end.sort
end
|
Instance Method Details
#choose_with_partitions ⇒ Object
19
20
21
|
# File 'lib/diskman/root_device.rb', line 19
def choose_with_partitions
Chooser.new(get_with_partitions, item: 'block device').select
end
|
#ensure_not_mounted! ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/diskman/root_device.rb', line 23
def ensure_not_mounted!
if mounted?
puts ('Warning: device appears to be mounted at ' + mount_point).yellow
puts 'Not continuing'.red
raise Interrupt
end
end
|
#to_s ⇒ Object
31
32
33
|
# File 'lib/diskman/root_device.rb', line 31
def to_s
@path + ' [' + [size, label].reject(&:empty?).join(', ') + ']'
end
|