Class: ActiveSupport::Inflector::Inflections::Uncountables
- Inherits:
-
Array
- Object
- Array
- ActiveSupport::Inflector::Inflections::Uncountables
show all
- Defined in:
- lib/active_support/inflector/inflections.rb
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, #present?, #second, #second_to_last, #split, #third, #third_to_last, #to, #to_fs, #to_param, #to_query, #to_sentence, #to_xml, wrap
Constructor Details
Returns a new instance of Uncountables.
34
35
36
37
|
# File 'lib/active_support/inflector/inflections.rb', line 34
def initialize
@regex_array = []
super
end
|
Instance Method Details
#<<(*word) ⇒ Object
44
45
46
|
# File 'lib/active_support/inflector/inflections.rb', line 44
def <<(*word)
add(word)
end
|
#add(words) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/active_support/inflector/inflections.rb', line 48
def add(words)
words = words.flatten.map(&:downcase)
concat(words)
@regex_array += words.map { |word| to_regex(word) }
self
end
|
#delete(entry) ⇒ Object
39
40
41
42
|
# File 'lib/active_support/inflector/inflections.rb', line 39
def delete(entry)
super entry
@regex_array.delete(to_regex(entry))
end
|
#uncountable?(str) ⇒ Boolean
55
56
57
|
# File 'lib/active_support/inflector/inflections.rb', line 55
def uncountable?(str)
@regex_array.any? { |regex| regex.match? str }
end
|