Class: Cyc::Builder
- Inherits:
-
Object
- Object
- Cyc::Builder
- Defined in:
- lib/cyc/builder.rb
Overview
This class is used to capture calls to the Cyc client, to allow nested calls, like
cyc.with_any_mt do |cyc|
cyc.comment :Collection
end
Instance Method Summary (collapse)
-
- (Builder) initialize
constructor
A new instance of Builder.
- - (Object) method_missing(name, *args, &block)
- - (Object) reset
- - (Object) to_cyc
Constructor Details
- (Builder) initialize
A new instance of Builder
9 10 11 |
# File 'lib/cyc/builder.rb', line 9 def initialize reset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(name, *args, &block)
21 22 23 24 25 26 27 28 |
# File 'lib/cyc/builder.rb', line 21 def method_missing(name,*args,&block) @query << "(" << name.to_s.gsub("_","-") << " " @query << (args||[]).map{|a| a.to_cyc}.join(" ") if block block.call(self) end @query << ")" end |
Instance Method Details
- (Object) reset
13 14 15 |
# File 'lib/cyc/builder.rb', line 13 def reset @query = "" end |
- (Object) to_cyc
17 18 19 |
# File 'lib/cyc/builder.rb', line 17 def to_cyc @query end |