Class: CFBundle::Resource::Enumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cfbundle/resource.rb

Overview

Performs the enumeration of a bundle’s resources.

Instance Method Summary collapse

Constructor Details

#initialize(bundle, subdirectory, localization, preferred_languages) ⇒ Enumerator

Returns a new instance of Enumerator.

Parameters:

  • bundle (Bundle)

    The bundle that contains the resources.

  • subdirectory (String?)

    The name of the bundle subdirectory to search.

  • localization (String?, Symbol?)

    A language identifier to restrict the search to a specific localization.

  • preferred_languages (Array)

    An array of strings (or symbols) corresponding to a user’s preferred languages.



76
77
78
79
80
81
82
# File 'lib/cfbundle/resource.rb', line 76

def initialize(bundle, subdirectory, localization, preferred_languages)
  @bundle = bundle
  @directory = PathUtils.join(bundle.resources_directory, subdirectory)
  @localizations = localizations_for(bundle, localization,
                                     preferred_languages)
  @enumerator = [].to_enum
end

Instance Method Details

#nextResource

Returns the next resource in the bundle.

Returns:

Raises:

  • (StopIteration)


88
89
90
91
92
93
# File 'lib/cfbundle/resource.rb', line 88

def next
  Resource.new(@bundle, @enumerator.next)
rescue StopIteration
  @enumerator = next_enumerator
  retry
end