Class: LyndaTranslatorSrt::SrtOriginal::Unzipper

Inherits:
Object
  • Object
show all
Defined in:
lib/lynda_translator_srt/srt_original/unzipper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tmp_file_path) ⇒ Unzipper

Returns a new instance of Unzipper.



8
9
10
# File 'lib/lynda_translator_srt/srt_original/unzipper.rb', line 8

def initialize(tmp_file_path)
  @tmp_file_path = tmp_file_path
end

Instance Attribute Details

#path_unzip_folderObject (readonly)

Returns the value of attribute path_unzip_folder.



6
7
8
# File 'lib/lynda_translator_srt/srt_original/unzipper.rb', line 6

def path_unzip_folder
  @path_unzip_folder
end

Instance Method Details

#unzipObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lynda_translator_srt/srt_original/unzipper.rb', line 12

def unzip
  name_unzip_folder = "srt_original_#{Time.now.utc.iso8601}"
  @path_unzip_folder = Dir.tmpdir + "/" + name_unzip_folder

  FileUtils::mkdir_p @path_unzip_folder

  @unzipped = system "unzip -o #{@tmp_file_path} -d #{@path_unzip_folder}"
  FileUtils::rm @tmp_file_path if unzipped?

  if unzipped?
    puts "Unzipped course"

    self
  else
    raise("Unfortunately we doesn't unzipped transcript to this course.")
  end
end

#unzipped?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/lynda_translator_srt/srt_original/unzipper.rb', line 30

def unzipped?
  @unzipped
end