class TwitterCldr::Shared::PropertyValueAliases

Public Class Methods

abbreviated_alias_for(property_name, property_value) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 12
def abbreviated_alias_for(property_name, property_value)
  (find_index_for(property_name, property_value) || {})
    .fetch(property_value, {})
    .fetch(:abbreviated_name, nil)
end
aliases_for(property_name, property_value) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 30
def aliases_for(property_name, property_value)
  aliases = [
    abbreviated_alias_for(property_name, property_value),
    long_alias_for(property_name, property_value),
    numeric_alias_for(property_name, property_value)
  ].compact

  aliases.delete(property_value)
  aliases
end
long_alias_for(property_name, property_value) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 18
def long_alias_for(property_name, property_value)
  (find_index_for(property_name, property_value) || {})
    .fetch(property_value, {})
    .fetch(:long_name, nil)
end
numeric_alias_for(property_name, property_value) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 24
def numeric_alias_for(property_name, property_value)
  (find_index_for(property_name, property_value) || {})
    .fetch(property_value, {})
    .fetch(:numeric, nil)
end

Private Class Methods

abbreviated_index_for(property_name) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 57
def abbreviated_index_for(property_name)
  abbreviated_indices[property_name] ||=
    create_index(property_name, :abbreviated_name)
end
abbreviated_indices() click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 78
def abbreviated_indices
  @abbreviated_indices ||= {}
end
create_index(property_name, field) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 72
def create_index(property_name, field)
  (resource[property_name] || {}).each_with_object({}) do |fields, ret|
    ret[fields[field]] = fields
  end
end
find_index_for(property_name, property_value) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 43
def find_index_for(property_name, property_value)
  indices_for(property_name).find do |index|
    index.include?(property_value)
  end
end
indices_for(property_name) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 49
def indices_for(property_name)
  [
    abbreviated_index_for(property_name),
    long_index_for(property_name),
    numeric_index_for(property_name)
  ].compact
end
long_index_for(property_name) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 62
def long_index_for(property_name)
  long_indices[property_name] ||=
    create_index(property_name, :long_name)
end
long_indices() click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 82
def long_indices
  @long_indices ||= {}
end
numeric_index_for(property_name) click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 67
def numeric_index_for(property_name)
  numeric_indices[property_name] ||=
    create_index(property_name, :numeric)
end
numeric_indices() click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 86
def numeric_indices
  @numeric_indices ||= {}
end
resource() click to toggle source
# File lib/twitter_cldr/shared/property_value_aliases.rb, line 90
def resource
  @resource ||=
    TwitterCldr.get_resource('unicode_data', 'property_value_aliases')
end