Class: Omnizip::Models::ExtractionRule
- Inherits:
-
Object
- Object
- Omnizip::Models::ExtractionRule
- Defined in:
- lib/omnizip/models/extraction_rule.rb
Overview
Represents a rule for extracting files from an archive
Defines what files to extract and how to extract them using patterns, predicates, and options.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
-
#predicates ⇒ Object
readonly
Returns the value of attribute predicates.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get option value.
-
#[]=(key, value) ⇒ Object
Set option value.
-
#add_pattern(pattern) ⇒ self
Add a pattern to the rule.
-
#add_predicate(&predicate) ⇒ self
Add a predicate to the rule.
-
#conditions? ⇒ Boolean
Check if the rule has any conditions.
-
#flatten? ⇒ Boolean
Check if paths should be flattened.
-
#initialize(patterns: [], predicates: [], options: {}) ⇒ ExtractionRule
constructor
Initialize a new extraction rule.
-
#overwrite? ⇒ Boolean
Check if existing files should be overwritten.
-
#patterns? ⇒ Boolean
Check if any patterns are defined.
-
#predicates? ⇒ Boolean
Check if any predicates are defined.
-
#preserve_paths? ⇒ Boolean
Check if paths should be preserved.
Constructor Details
#initialize(patterns: [], predicates: [], options: {}) ⇒ ExtractionRule
Initialize a new extraction rule
21 22 23 24 25 |
# File 'lib/omnizip/models/extraction_rule.rb', line 21 def initialize(patterns: [], predicates: [], options: {}) @patterns = Array(patterns) @predicates = Array(predicates) @options = .merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/omnizip/models/extraction_rule.rb', line 10 def @options end |
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
10 11 12 |
# File 'lib/omnizip/models/extraction_rule.rb', line 10 def patterns @patterns end |
#predicates ⇒ Object (readonly)
Returns the value of attribute predicates.
10 11 12 |
# File 'lib/omnizip/models/extraction_rule.rb', line 10 def predicates @predicates end |
Instance Method Details
#[](key) ⇒ Object
Get option value
70 71 72 |
# File 'lib/omnizip/models/extraction_rule.rb', line 70 def [](key) @options[key] end |
#[]=(key, value) ⇒ Object
Set option value
78 79 80 |
# File 'lib/omnizip/models/extraction_rule.rb', line 78 def []=(key, value) @options[key] = value end |
#add_pattern(pattern) ⇒ self
Add a pattern to the rule
31 32 33 34 |
# File 'lib/omnizip/models/extraction_rule.rb', line 31 def add_pattern(pattern) @patterns << pattern self end |
#add_predicate(&predicate) ⇒ self
Add a predicate to the rule
40 41 42 43 |
# File 'lib/omnizip/models/extraction_rule.rb', line 40 def add_predicate(&predicate) @predicates << predicate if predicate self end |
#conditions? ⇒ Boolean
Check if the rule has any conditions
62 63 64 |
# File 'lib/omnizip/models/extraction_rule.rb', line 62 def conditions? patterns? || predicates? end |
#flatten? ⇒ Boolean
Check if paths should be flattened
92 93 94 |
# File 'lib/omnizip/models/extraction_rule.rb', line 92 def flatten? @options[:flatten] end |
#overwrite? ⇒ Boolean
Check if existing files should be overwritten
99 100 101 |
# File 'lib/omnizip/models/extraction_rule.rb', line 99 def overwrite? @options[:overwrite] end |
#patterns? ⇒ Boolean
Check if any patterns are defined
48 49 50 |
# File 'lib/omnizip/models/extraction_rule.rb', line 48 def patterns? !@patterns.empty? end |
#predicates? ⇒ Boolean
Check if any predicates are defined
55 56 57 |
# File 'lib/omnizip/models/extraction_rule.rb', line 55 def predicates? !@predicates.empty? end |
#preserve_paths? ⇒ Boolean
Check if paths should be preserved
85 86 87 |
# File 'lib/omnizip/models/extraction_rule.rb', line 85 def preserve_paths? @options[:preserve_paths] end |