Class: ActiveSupport::Inflector::Inflections::Uncountables
- Inherits:
-
Array
- Object
- Array
- ActiveSupport::Inflector::Inflections::Uncountables
show all
- Defined in:
- lib/active_support/inflector/inflections.rb
Constant Summary
Constants inherited
from Array
Array::NOT_SET
Instance Method Summary
collapse
Methods inherited from Array
#as_json, #compact_blank!, #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_default_s, #to_fs, #to_param, #to_query, #to_s, #to_sentence, #to_xml, wrap
Constructor Details
Returns a new instance of Uncountables.
32
33
34
35
|
# File 'lib/active_support/inflector/inflections.rb', line 32
def initialize
@regex_array = []
super
end
|
Instance Method Details
#<<(*word) ⇒ Object
42
43
44
|
# File 'lib/active_support/inflector/inflections.rb', line 42
def <<(*word)
add(word)
end
|
#add(words) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/active_support/inflector/inflections.rb', line 46
def add(words)
words = words.flatten.map(&:downcase)
concat(words)
@regex_array += words.map { |word| to_regex(word) }
self
end
|
#delete(entry) ⇒ Object
37
38
39
40
|
# File 'lib/active_support/inflector/inflections.rb', line 37
def delete(entry)
super entry
@regex_array.delete(to_regex(entry))
end
|
#uncountable?(str) ⇒ Boolean
53
54
55
|
# File 'lib/active_support/inflector/inflections.rb', line 53
def uncountable?(str)
@regex_array.any? { |regex| regex.match? str }
end
|