Method: Cyc::Client#method_missing

Defined in:
lib/cyc/client.rb

#method_missing(name, *args, &block) ⇒ Object

This hook allows for direct call on the Client class, that are translated into corresponding calls for Cyc server.

E.g. if users initializes the client and calls some Ruby method

cyc = Cyc::Client.new
cyc.genls? :Dog, :Animal

He/She returns a parsed answer from the server:

=> true

Since dashes are not allowed in Ruby method names they are replaced with underscores:

cyc.min_genls :Dog

is translated into:

(min-genls #$Dog)

As you see the Ruby symbols are translated into Cyc terms (not Cyc symbols!).

It is also possible to nest the calls to build more complex calls:

cyc.with_any_mt do |cyc|
  cyc.min_genls :Dog
end

is translated into:

(with-any-mt (min-genls #$Dog))


272
273
274
275
276
# File 'lib/cyc/client.rb', line 272

def method_missing(name,*args,&block)
  builder = Builder.new
  builder.send(name,*args,&block)
  talk(builder.to_cyc)
end