Class: Tools::Actions::Create
- Inherits:
-
Object
- Object
- Tools::Actions::Create
- Includes:
- Support::Execution, Support::Manifest
- Defined in:
- lib/tools/actions/create.rb
Instance Attribute Summary collapse
-
#announce ⇒ Object
readonly
Returns the value of attribute announce.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#piece_size ⇒ Object
readonly
Returns the value of attribute piece_size.
-
#privacy ⇒ Object
readonly
Returns the value of attribute privacy.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#execute ⇒ Object
Create a .torrent file for every file in the manifest.
-
#initialize(manifest:, announce:, source:, output:, piece_size:, privacy:) ⇒ Create
constructor
Create creates .torrent files for all files found in its manifest.
Methods included from Support::Execution
Constructor Details
#initialize(manifest:, announce:, source:, output:, piece_size:, privacy:) ⇒ Create
Create creates .torrent files for all files found in its manifest.
19 20 21 22 23 24 25 26 27 |
# File 'lib/tools/actions/create.rb', line 19 def initialize(manifest:, announce:, source:, output:, piece_size:, privacy:) @announce = announce @source = source @output = output @piece_size = piece_size @privacy = privacy @files = extract_files(manifest) end |
Instance Attribute Details
#announce ⇒ Object (readonly)
Returns the value of attribute announce.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def announce @announce end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def files @files end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def output @output end |
#piece_size ⇒ Object (readonly)
Returns the value of attribute piece_size.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def piece_size @piece_size end |
#privacy ⇒ Object (readonly)
Returns the value of attribute privacy.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def privacy @privacy end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/tools/actions/create.rb', line 10 def source @source end |
Instance Method Details
#execute ⇒ Object
Create a .torrent file for every file in the manifest
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tools/actions/create.rb', line 30 def execute create_output_directory files.each do |file_name| # Full relative path to the source file infile_path = source_path(file_name) # File name of output file outfile_name = torrent_name(file_name) # Full relative path to output file outfile_path = output_path(outfile_name) if can_create_torrent?(infile_path) make_torrent(infile_path, outfile_path) puts "√ #{outfile_name}" end end end |