Class: ActiveSupport::Inflector::Inflections::Uncountables

Inherits:
Array
  • Object
show all
Defined in:
lib/active_support/inflector/inflections.rb

Instance Method Summary collapse

Methods inherited from Array

#as_json, #deep_dup, #excluding, #extract!, #extract_options!, #fifth, #forty_two, #fourth, #from, #in_groups, #in_groups_of, #including, #inquiry, #second, #second_to_last, #split, #sum, #third, #third_to_last, #to, #to_formatted_s, #to_param, #to_query, #to_sentence, #to_xml, #without, wrap

Constructor Details

#initializeUncountables

Returns a new instance of Uncountables.



33
34
35
36
# File 'lib/active_support/inflector/inflections.rb', line 33

def initialize
  @regex_array = []
  super
end

Instance Method Details

#<<(*word) ⇒ Object



43
44
45
# File 'lib/active_support/inflector/inflections.rb', line 43

def <<(*word)
  add(word)
end

#add(words) ⇒ Object



47
48
49
50
51
52
# File 'lib/active_support/inflector/inflections.rb', line 47

def add(words)
  words = words.flatten.map(&:downcase)
  concat(words)
  @regex_array += words.map { |word| to_regex(word) }
  self
end

#delete(entry) ⇒ Object



38
39
40
41
# File 'lib/active_support/inflector/inflections.rb', line 38

def delete(entry)
  super entry
  @regex_array.delete(to_regex(entry))
end

#uncountable?(str) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_support/inflector/inflections.rb', line 54

def uncountable?(str)
  @regex_array.any? { |regex| regex.match? str }
end