Class: Command::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/diskman/commands/write.rb

Instance Method Summary collapse

Instance Method Details

#run(file:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/diskman/commands/write.rb', line 3

def run(file:)
    if !File.exist?(file)
        puts ('Unable to read ' + file).red
        raise Interrupt
    end

    device = RootDevice.choose
    device = device.choose_with_partitions

    size = File.size(file)
    cmd = device.get_write_command(file)

    puts "File:    #{file.yellow} (#{System.bytes2human(size)})"
    puts "Device:  #{device.to_s.yellow}"
    puts "Command: #{cmd.yellow}"

    System.exec!(cmd)
end