Module Linguistics
In: lib/linguistics.rb
lib/linguistics/iso639.rb

linguistics/iso639.rb - A hash of International 2- and 3-letter ISO639-1 and ISO639-2 language codes. Each entry has two keys:

:codes
All of the codes known for this language
:desc
The English-language description of the language.

Copyright (c) 2003-2008, Michael Granger All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

  * Neither the name of the author/s, nor the names of the project's
    contributors may be used to endorse or promote products derived from this
    software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Methods

Classes and Modules

Module Linguistics::EN
Class Linguistics::LanguageProxyClass

Constants

VERSION = '1.0.9'   Release version
DefaultLanguages = []   Language module implementors should do something like:
  Linguistics::DefaultLanguages.push( :ja ) # or whatever

so that direct requiring of a language module sets the default.

DefaultExtClasses = [String, Numeric, Array]   The list of Classes to add linguistic behaviours to.
LanguageCodes = {}   Hash of ISO639 2- and 3-letter language codes

Public Class methods

Handle auto-magic usage

Extend the specified target object with one or more language proxy methods, each of which provides access to one or more linguistic methods for that language.

Extend the including class with linguistics proxy methods.

Install a regular proxy method in the given klass that will delegate calls to missing method to the languageProxy for the given language.

Make an languageProxy class that encapsulates all of the inflect operations using the given language module.

Public Instance methods

NUM()

Alias for #num

NUM=( val )

Alias for #num=

Set the ‘classical pluralizations’ flag to val. Setting is local to calling thread.

Return the value of the ‘classical pluralizations’ flag. Setting is local to calling thread.

Get the default count for all unspecified plurals. Setting is local to calling thread.

Set the default count for all unspecified plurals to val. Setting is local to calling thread.

Add linguistics functions for the specified languages to Ruby‘s core classes. The interface to all linguistic functions for a given language is through a method which is the same the language‘s international 2- or 3-letter code (ISO 639). You can also specify a Hash of configuration options which control which classes are extended:

:classes
Specify the classes which are to be extended. If this is not specified, the Class objects in Linguistics::DefaultExtClasses (an Array) are extended.
:installProxy
Install a proxy method in each of the classes which are to be extended which will search for missing methods in the languageProxy for the language code specified as the value. This allows linguistics methods to be called directly on extended objects directly (e.g., 12.en.ordinal becomes 12.ordinal). Obviously, methods which would collide with the object‘s builtin methods will need to be invoked through the languageProxy. Any existing proxy methods in the extended classes will be preserved.

[Validate]