Class: OsCtl::Image::Operations::File::Compare

Inherits:
Base
  • Object
show all
Includes:
Lib::Utils::Log, Lib::Utils::System
Defined in:
lib/osctl/image/operations/file/compare.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

run

Constructor Details

#initialize(file1, file2) ⇒ Compare

Returns a new instance of Compare.

Parameters:

  • file1 (String)
  • file2 (String)


14
15
16
17
# File 'lib/osctl/image/operations/file/compare.rb', line 14

def initialize(file1, file2)
  super()
  @files = [file1, file2]
end

Instance Attribute Details

#filesArray (readonly)

Returns:

  • (Array)


10
11
12
# File 'lib/osctl/image/operations/file/compare.rb', line 10

def files
  @files
end

Instance Method Details

#executeBoolean

Returns true if the files are same.

Returns:

  • (Boolean)

    true if the files are same



20
21
22
23
# File 'lib/osctl/image/operations/file/compare.rb', line 20

def execute
  ret = syscmd("cmp -s \"#{@files[0]}\" \"#{@files[1]}\"", valid_rcs: [1, 2])
  ret.exitstatus == 0
end