Method: I18n::Inflector::InflectionData#each_raw_token

Defined in:
lib/i18n-inflector/inflection_data.rb

#each_raw_tokenLazyHashEnumerator #each_raw_token(kind) ⇒ LazyHashEnumerator

Note:

True tokens have descriptions (String) and aliases have targets (Symbol) assigned.

Iterates through all the tokens in a way that it is possible to distinguish true tokens from aliases.

Overloads:

  • #each_raw_tokenLazyHashEnumerator

    Reads all the tokens in a way that it is possible to distinguish true tokens from aliases.

    Returns:

  • #each_raw_token(kind) ⇒ LazyHashEnumerator

    Reads all the tokens of the given kind in a way that it is possible to distinguish true tokens from aliases.

    Parameters:

    • kind (Symbol)

      the identifier of a kind

    Returns:

Yields:

  • (token, value)

    optional block in which each token will be yielded

Yield Parameters:

  • token (Symbol)

    a token

  • value (Symbol, String)

    a description string for a token or a target (if alias)

Yield Returns:

Returns:

[View source]

220
221
222
223
224
225
# File 'lib/i18n-inflector/inflection_data.rb', line 220

def each_raw_token(kind=nil, &block)
  t = @lazy_tokens
  t = t.select  { |token,data| data[:kind] == kind } unless kind.nil?
  t.map         { |token,data| data[:target] || data[:description]  }.
  each(&block)
end