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.



103
104
105
106
107
108
109
# File 'lib/cfbundle/resource.rb', line 103

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)


115
116
117
118
119
120
# File 'lib/cfbundle/resource.rb', line 115

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