Class: CFBundle::Resource::Predicate

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(name, extension, product) ⇒ Predicate

Returns a new instance of Predicate.

Parameters:

  • name (String?)

    The name to match or nil to match any name.

  • extension (String?)

    The extension to match or nil to match any extension.

  • product (String?)

    The product to match.



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

#extensionString? (readonly)

Returns the extension to match or nil to match any extension.

Returns:

  • (String?)


161
162
163
# File 'lib/cfbundle/resource.rb', line 161

def extension
  @extension
end

#nameString? (readonly)

Returns the name to match or nil to match any name.

Returns:

  • (String?)


157
158
159
# File 'lib/cfbundle/resource.rb', line 157

def name
  @name
end

#productString (readonly)

Returns the product to match.

Returns:

  • (String)


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.

Parameters:

  • name (String)

    The resource name.

  • extension (String)

    The resource extension.

Returns:

  • (Boolean)


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