Class: M3u8::CLI::DiffCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/m3u8/cli/diff_command.rb

Overview

DiffCommand reports structural differences between two playlists by comparing their normalized Hash representations.

Instance Method Summary collapse

Constructor Details

#initialize(first, second, stdout) ⇒ DiffCommand

Returns a new instance of DiffCommand.



8
9
10
11
12
# File 'lib/m3u8/cli/diff_command.rb', line 8

def initialize(first, second, stdout)
  @first = first.to_h
  @second = second.to_h
  @stdout = stdout
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/m3u8/cli/diff_command.rb', line 14

def run
  if @first == @second
    @stdout.puts 'Identical'
    return 0
  end

  diff_hash('', without_items(@first), without_items(@second))
  diff_items
  1
end