Class: SafeZip::ExtractParams
- Inherits:
-
Object
- Object
- SafeZip::ExtractParams
- Defined in:
- lib/safe_zip/extract_params.rb
Instance Attribute Summary collapse
-
#directories ⇒ Object
readonly
Returns the value of attribute directories.
-
#extract_path ⇒ Object
readonly
Returns the value of attribute extract_path.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #directories_wildcard ⇒ Object
-
#initialize(to:, directories: [], files: []) ⇒ ExtractParams
constructor
A new instance of ExtractParams.
- #matching_target_directory(path) ⇒ Object
- #matching_target_file(path) ⇒ Object
- #target_directories ⇒ Object
Constructor Details
#initialize(to:, directories: [], files: []) ⇒ ExtractParams
Returns a new instance of ExtractParams.
7 8 9 10 11 12 |
# File 'lib/safe_zip/extract_params.rb', line 7 def initialize(to:, directories: [], files: []) @directories = directories @files = files @extract_path = ::File.realpath(to) validate! end |
Instance Attribute Details
#directories ⇒ Object (readonly)
Returns the value of attribute directories.
5 6 7 |
# File 'lib/safe_zip/extract_params.rb', line 5 def directories @directories end |
#extract_path ⇒ Object (readonly)
Returns the value of attribute extract_path.
5 6 7 |
# File 'lib/safe_zip/extract_params.rb', line 5 def extract_path @extract_path end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/safe_zip/extract_params.rb', line 5 def files @files end |
Instance Method Details
#directories_wildcard ⇒ Object
26 27 28 29 30 |
# File 'lib/safe_zip/extract_params.rb', line 26 def directories_wildcard @directories_wildcard ||= directories.map do |directory| ::File.join(directory, '*') end end |
#matching_target_directory(path) ⇒ Object
14 15 16 17 18 |
# File 'lib/safe_zip/extract_params.rb', line 14 def matching_target_directory(path) target_directories.find do |directory| path.start_with?(directory) end end |
#matching_target_file(path) ⇒ Object
32 33 34 |
# File 'lib/safe_zip/extract_params.rb', line 32 def matching_target_file(path) target_files.include?(path) end |
#target_directories ⇒ Object
20 21 22 23 24 |
# File 'lib/safe_zip/extract_params.rb', line 20 def target_directories @target_directories ||= directories.map do |directory| ::File.join(::File.(directory, extract_path), '') end end |