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

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

Instance Method Summary collapse

Methods inherited from Array

#as_json, #deep_dup, #extract_options!, #fifth, #forty_two, #fourth, #from, #in_groups, #in_groups_of, #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.


31
32
33
34
# File 'activesupport/lib/active_support/inflector/inflections.rb', line 31

def initialize
  @regex_array = []
  super
end

Instance Method Details

#<<(*word) ⇒ Object


41
42
43
# File 'activesupport/lib/active_support/inflector/inflections.rb', line 41

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

#add(words) ⇒ Object


45
46
47
48
49
# File 'activesupport/lib/active_support/inflector/inflections.rb', line 45

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

#delete(entry) ⇒ Object


36
37
38
39
# File 'activesupport/lib/active_support/inflector/inflections.rb', line 36

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

#uncountable?(str) ⇒ Boolean

Returns:

  • (Boolean)

51
52
53
# File 'activesupport/lib/active_support/inflector/inflections.rb', line 51

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