Class: FuturoCube::VerifyCommand

Inherits:
Object
  • Object
show all
Includes:
CommandHelper
Defined in:
lib/futurocube/verify_command.rb

Instance Method Summary collapse

Methods included from CommandHelper

#with_progress

Instance Method Details

#args_valid?(args) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/futurocube/verify_command.rb', line 25

def args_valid?(args)
  args.length == 1
end

#exec(file) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/futurocube/verify_command.rb', line 8

def exec(file)
  ResourceFile.open(file) do |rf|
    expected = rf.header.checksum
    actual = with_progress('Checking', rf.header.file_size) do |progress|
      rf.compute_checksum do |done|
        progress.set(done)
      end
    end

    if actual == expected
      puts "  Checksum %08X OK" % [actual]
    else
      puts "  Checksum %08X NG (expected %08X)" % [actual, expected]
    end
  end
end

#usageObject



29
30
31
# File 'lib/futurocube/verify_command.rb', line 29

def usage
  "filename"
end