Class: RAR::Archive
- Inherits:
-
Object
- Object
- RAR::Archive
- Defined in:
- library/rar/archive.rb
Overview
The Archive class.
It is the main entry-point to creating a new archive.
Instance Attribute Summary collapse
-
#files ⇒ Array
The list of files.
-
#options ⇒ Hash
The list of options.
Instance Method Summary collapse
-
#add_file(path) ⇒ Array
Add a file to the list of files.
-
#create! ⇒ Object
Create the final archive.
-
#initialize(filename, options = {}) ⇒ Archive
constructor
Create a new archive.
Constructor Details
#initialize(filename, options = {}) ⇒ Archive
Create a new archive.
30 31 32 33 34 |
# File 'library/rar/archive.rb', line 30 def initialize filename, = {} @files = [] @options = CommandLineOptions.new.merge @filename = filename end |
Instance Attribute Details
#files ⇒ Array
Returns the list of files.
9 10 11 |
# File 'library/rar/archive.rb', line 9 def files @files end |
#options ⇒ Hash
Returns the list of options.
12 13 14 |
# File 'library/rar/archive.rb', line 12 def @options end |
Instance Method Details
#add_file(path) ⇒ Array
Add a file to the list of files.
40 41 42 43 44 45 46 |
# File 'library/rar/archive.rb', line 40 def add_file path if File.exist? path @files << path else raise Errno::ENOENT, "File '#{path}' doesn't exist" end end |
#create! ⇒ Object
Create the final archive.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'library/rar/archive.rb', line 52 def create! rar_process = IO.popen command_line # Wait for the child rar process to finish. _, status = Process.wait2 rar_process.pid if status.exitstatus > 1 if = ExitCodeMessages[status.exitstatus] raise CommandLineError, else raise CommandLineError, "Unknown exit status: #{status}" end else true end end |