Parent

Linguistics::LanguageProxyClass

A class which is inherited from by proxies for classes being extended with one or more linguistic interfaces. It provides on-the-fly creation of linguistic methods when the :installProxy option is passed to the call to Linguistics#use.

Attributes

langmod[RW]

Public Class Methods

new( receiver ) click to toggle source

Create a new LanguageProxy for the given receiver.

# File lib/linguistics.rb, line 60
def initialize( receiver )
    @receiver = receiver
end

Public Instance Methods

inspect() click to toggle source

Returns a human-readable representation of the languageProxy for debugging, logging, etc.

# File lib/linguistics.rb, line 92
def inspect
    "<%s languageProxy for %s object %s>" % [
        self.class.langmod.language,
        @receiver.class.name,
        @receiver.inspect,
    ]
end
method_missing( sym, *args, &block ) click to toggle source

Autoload linguistic methods defined in the module this object's class uses for inflection.

# File lib/linguistics.rb, line 77
def method_missing( sym, *args, &block )
    return super unless self.class.langmod.respond_to?( sym )

    self.class.module_eval %{
        def #{sym}( *args, &block )
            self.class.langmod.#{sym}( @receiver, *args, &block )
        end
    }, "{Autoloaded: " + __FILE__ + "}", __LINE__

    self.method( sym ).call( *args, &block )
end
respond_to?( sym ) click to toggle source

Overloaded to take into account the proxy method.

# File lib/linguistics.rb, line 70
def respond_to?( sym )
    self.class.langmod.respond_to?( sym ) || super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.