class Linguistics::Inflector

A facade object that acts as the extension point for linguistic modules for a single language. A single instance of an inflector is generated for an object that has been extended with a Linguistics language the first time the language is used.

Attributes

language_code[R]

The inflector's language code

obj[R]

The object the inflector is delegating for

Public Class Methods

new( language_code, obj ) click to toggle source

Create a new inflector for obj.

Calls superclass method
# File lib/linguistics/inflector.rb, line 19
def initialize( language_code, obj )
        raise TypeError, "can't inflect for another inflector!" if
                obj.is_a?( Linguistics::Inflector )
        @language_code = language_code
        @obj = obj
        super()
end

Public Instance Methods

inspect() click to toggle source

Output a programmer-readable representation of the object suitable for debugging.

# File lib/linguistics/inflector.rb, line 66
def inspect
        return "#<(%s-language inflector) for <%s:0x%0x> >" % [
                self.language,
                @obj.class,
                @obj.object_id / 2
        ]
end
language() click to toggle source

Return the english-language name of the language the inflector is delegating for.

# File lib/linguistics/inflector.rb, line 41
def language
        ::Linguistics::ISO639::LANGUAGE_CODES[ self.language_code.to_sym ][:eng_name]
end
respond_to_missing?( message, include_priv=false ) click to toggle source

Returns true if either the inflector or the object it's wrapping respond to the specified message.

# File lib/linguistics/inflector.rb, line 48
def respond_to_missing?( message, include_priv=false )
        return self.obj.respond_to?( message, include_priv )
end
to_i() click to toggle source

Return the target object as an Integer

# File lib/linguistics/inflector.rb, line 60
def to_i
        return self.obj.to_i
end
to_s() click to toggle source

Return the target object as a String.

# File lib/linguistics/inflector.rb, line 54
def to_s
        return self.obj.to_s
end

Protected Instance Methods

method_missing( sym, *args, &block ) click to toggle source

Delegate missing methods to the target object.

Calls superclass method
# File lib/linguistics/inflector.rb, line 80
def method_missing( sym, *args, &block )
        return super unless self.obj.respond_to?( sym )
        meth = self.obj.method( sym )
        self.singleton_class.send( :define_method, sym, &meth )
        return self.method( sym ).call( *args, &block )
end