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?, Rexgep?)

    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.



175
176
177
178
179
180
# File 'lib/cfbundle/resource.rb', line 175

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?)


164
165
166
# File 'lib/cfbundle/resource.rb', line 164

def extension
  @extension
end

#nameString?, Regexp? (readonly)

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

Returns:

  • (String?, Regexp?)


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

def name
  @name
end

#productString (readonly)

Returns the product to match.

Returns:

  • (String)


168
169
170
# File 'lib/cfbundle/resource.rb', line 168

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)


186
187
188
189
190
191
# File 'lib/cfbundle/resource.rb', line 186

def uniq?(name, extension)
  key = [name, extension].join
  return false if @keys.include?(key)
  @keys << key
  true
end