Method: I18n::Inflector::InflectionData_Strict#add_token

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

#add_token(token, kind, description) ⇒ Boolean

Adds a token (overwriting existing token).

Parameters:

  • token (Symbol)

    the name of a token to add

  • kind (Symbol)

    the identifier of a kind

  • description (String)

    the description of a token

Returns:

  • (Boolean)

    true if everything went ok, false otherwise (in case of bad names)

[View source]

75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/i18n-inflector/inflection_data_strict.rb', line 75

def add_token(token, kind, description)
  return false if (token.to_s.empty? || kind.to_s.empty? || description.nil?)
  token     = token.to_sym
  kind      = kind.to_sym
  kind_tree = @tokens[kind]
  if kind_tree.equal?(DUMMY_TOKENS)
    kind_tree = @tokens[kind] = Hash.new(DUMMY_TOKEN)
  end
  token = kind_tree[token] = {}
  token[:description] = description.to_s
  true
end