Class: CFBundle::Resource::Predicate
- Inherits:
-
Object
- Object
- CFBundle::Resource::Predicate
- Defined in:
- lib/cfbundle/resource.rb
Overview
Stores the parameters to select the matching resources while enumerating the resources of a bundle.
Instance Attribute Summary collapse
-
#extension ⇒ String?
readonly
Returns the extension to match or
nilto match any extension. -
#name ⇒ String?
readonly
Returns the name to match or
nilto match any name. -
#product ⇒ String
readonly
Returns the product to match.
Instance Method Summary collapse
-
#initialize(name, extension, product) ⇒ Predicate
constructor
A new instance of Predicate.
-
#uniq?(name, extension) ⇒ Boolean
Ensures the given name and extension are unique during the enumeration.
Constructor Details
#initialize(name, extension, product) ⇒ Predicate
Returns a new instance of Predicate.
171 172 173 174 175 176 |
# File 'lib/cfbundle/resource.rb', line 171 def initialize(name, extension, product) @name = name @extension = extension_for(extension) @product = product_for(product) @keys = Set.new end |
Instance Attribute Details
#extension ⇒ String? (readonly)
Returns the extension to match or nil to match any extension.
161 162 163 |
# File 'lib/cfbundle/resource.rb', line 161 def extension @extension end |
#name ⇒ String? (readonly)
Returns the name to match or nil to match any name.
157 158 159 |
# File 'lib/cfbundle/resource.rb', line 157 def name @name end |
#product ⇒ String (readonly)
Returns the product to match.
165 166 167 |
# File 'lib/cfbundle/resource.rb', line 165 def product @product end |
Instance Method Details
#uniq?(name, extension) ⇒ Boolean
Ensures the given name and extension are unique during the enumeration.
182 183 184 185 186 187 |
# File 'lib/cfbundle/resource.rb', line 182 def uniq?(name, extension) key = [name, extension].join return false if @keys.include?(key) @keys << key true end |