123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Array
Instance Chain:
self, ::Array
Inherits: Array
  • ::Object
Defined in: activesupport/lib/active_support/inflector/inflections.rb

Class Method Summary

::Array - Inherited

.wrap

Wraps its argument in an array unless it is already an array (or array-like).

Instance Method Summary

::Array - Inherited

#blank?

An array is blank if it’s empty:

#deep_dup

Returns a deep copy of array.

#excluding

Returns a copy of the ::Array excluding the specified elements.

#extract!

Removes and returns the elements for which the block returns a true value.

#extract_options!

Extracts options from a set of arguments.

#fifth

Equal to self[4].

#forty_two

Equal to self[41].

#fourth

Equal to self[3].

#from

Returns the tail of the array from position.

#in_groups

Splits or iterates over the array in number of groups, padding any remaining slots with fill_with unless it is false.

#in_groups_of

Splits or iterates over the array in groups of size number, padding any remaining slots with fill_with unless it is false.

#including

Returns a new array that includes the passed elements.

#inquiry

Wraps the array in an ::ActiveSupport::ArrayInquirer object, which gives a friendlier way to check its string-like contents.

#second

Equal to self[1].

#second_to_last

Equal to self[-2].

#split

Divides the array into one or more subarrays based on a delimiting value or the result of an optional block.

#third

Equal to self[2].

#third_to_last

Equal to self[-3].

#to

Returns the beginning of the array up to position.

#to_formatted_s

Alias for Array#to_fs.

#to_fs

Extends Array#to_s to convert a collection of elements into a comma separated id list if :db argument is given as the format.

#to_param

Calls to_param on all its elements and joins the result with slashes.

#to_query

Converts an array into a string suitable for use as a URL query string, using the given key as the param name.

#to_sentence

Converts the array to a comma-separated sentence where the last element is joined by the connector word.

#to_xml

Returns a string that represents the array in XML by invoking to_xml on each element.

#without

Alias for Array#excluding.

Constructor Details

.newUncountables

[ GitHub ]

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

def initialize
  @regex_array = []
  super
end

Instance Method Details

#<<(*word)

[ GitHub ]

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

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

#add(words)

[ GitHub ]

  
# File 'activesupport/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)

[ GitHub ]

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

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

#uncountable?(str) ⇒ Boolean

[ GitHub ]

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

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