Module: Awesome::Definitions::Locales::ClassMethods
- Defined in:
- lib/awesome/definitions/locales.rb
Instance Method Summary collapse
- #get_class_for_locale(locale) ⇒ Object
- #get_locale_modifiers(anytext, locale = nil) ⇒ Object
- #get_search_locale_from_modifier(mod) ⇒ Object
- #search_locale_keys(symring = true) ⇒ Object
- #search_locale_modifiers(symring = true) ⇒ Object
- #search_locale_modifiers_regex(whitespace = false) ⇒ Object
- #search_locales_enabled ⇒ Object
- #stopwords_for_locale(locale) ⇒ Object
- #valid_locale_modifiers(anytext, locale) ⇒ Object
Instance Method Details
#get_class_for_locale(locale) ⇒ Object
21 22 23 |
# File 'lib/awesome/definitions/locales.rb', line 21 def get_class_for_locale(locale) self.get_class(self.search_locales[:search_locales_to_classes][locale]) end |
#get_locale_modifiers(anytext, locale = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/awesome/definitions/locales.rb', line 48 def get_locale_modifiers(anytext, locale = nil) mods = anytext.scan(self.search_locale_modifiers_regex(false)).flatten.compact #If no locale mods are in the search string then the locale requested is valid so we pretend it was requested as a modifier mods = !locale.blank? && mods.empty? ? [self.make_symring(locale)] : mods puts "get_locale_modifiers: #{mods.reject {|x| x == ''}.inspect}" if self.verbose_locales mods.reject {|x| x == ''} end |
#get_search_locale_from_modifier(mod) ⇒ Object
56 57 58 |
# File 'lib/awesome/definitions/locales.rb', line 56 def get_search_locale_from_modifier(mod) self.search_locales[:locale_modifiers_to_search_locales][mod] end |
#search_locale_keys(symring = true) ⇒ Object
25 26 27 |
# File 'lib/awesome/definitions/locales.rb', line 25 def search_locale_keys(symring = true) self.search_locales[:search_locales_to_locale_modifiers].map {|k,v| symring ? k : self.unmake_symring(k)} end |
#search_locale_modifiers(symring = true) ⇒ Object
29 30 31 32 |
# File 'lib/awesome/definitions/locales.rb', line 29 def search_locale_modifiers(symring = true) # Needs to be flattened because the values are arrays self.search_locales[:search_locales_to_locale_modifiers].map {|k,v| symring ? v : self.unmake_symring(v)}.flatten end |
#search_locale_modifiers_regex(whitespace = false) ⇒ Object
60 61 62 |
# File 'lib/awesome/definitions/locales.rb', line 60 def search_locale_modifiers_regex(whitespace = false) self.modifier_regex_from_array(self.search_locale_modifiers, whitespace) end |
#search_locales_enabled ⇒ Object
17 18 19 |
# File 'lib/awesome/definitions/locales.rb', line 17 def search_locales_enabled self.search_locale_keys(false) end |
#stopwords_for_locale(locale) ⇒ Object
13 14 15 |
# File 'lib/awesome/definitions/locales.rb', line 13 def stopwords_for_locale(locale) self.search_locales[:search_locales_to_stopwords][locale] end |
#valid_locale_modifiers(anytext, locale) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/awesome/definitions/locales.rb', line 34 def valid_locale_modifiers(anytext, locale) # Weed out invalid locale requests puts "checking valid_locale_modifiers: #{anytext}, locale: #{locale.inspect}" if self.verbose_locales locale = self.make_symring(locale) return false unless self.search_locale_keys.include?(locale) mods = self.get_locale_modifiers(anytext, locale) valid_mods = mods.select do |mod| puts "locale mod #{mod.inspect} => #{self.get_search_locale_from_modifier(mod)} == #{locale.inspect}" if self.verbose_locales self.symring_equalizer(self.get_search_locale_from_modifier(mod), locale) end puts "valid_locale_modifiers: #{valid_mods.inspect}" if self.verbose_locales return valid_mods end |