clipsruby 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +388 -404
- data/ext/clipsruby/clipsruby.c +471 -27
- metadata +2 -2
data/README.md
CHANGED
@@ -17,8 +17,9 @@ and use the below API as described.
|
|
17
17
|
|
18
18
|
## API
|
19
19
|
|
20
|
-
###
|
21
|
-
|
20
|
+
### Environment Methods
|
21
|
+
|
22
|
+
#### `CLIPS.create_environment` / `CLIPS::Environment.new`
|
22
23
|
|
23
24
|
Create a new CLIPS environment in which you may define Rules,
|
24
25
|
assert Facts, and instantiate Objects.
|
@@ -28,8 +29,76 @@ env = CLIPS.create_environment
|
|
28
29
|
env2 = CLIPS::Environment.new
|
29
30
|
```
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
#### `CLIPS::Environment._eval` / `CLIPS::Environment#_eval`
|
33
|
+
|
34
|
+
Evaluates a passed string in the CLIPS environment and returns the results.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
CLIPS::Environment._eval(env, "(find-all-facts ((?f my_deftemplate)) TRUE)")
|
38
|
+
env._eval("(find-all-facts ((?f my_deftemplate)) TRUE)")
|
39
|
+
```
|
40
|
+
|
41
|
+
#### `CLIPS::Environment.build` / `CLIPS::Environment#build`
|
42
|
+
|
43
|
+
Build the constructs in the env as defined in a string
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
CLIPS::Environment.build(env, "(deftemplate my_template (slot a) (slot b) (slot c))")
|
47
|
+
env.build("(defrule do-a-thing (my_template (a ?a)) => (println \"a: \" ?a))")
|
48
|
+
```
|
49
|
+
|
50
|
+
#### `CLIPS::Environment.add_udf` / `CLIPS::Environment#add_udf`
|
51
|
+
|
52
|
+
Adds a ruby method as a User Defined Function (udf) to the CLIPS environment
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
class CLIPS::Environment
|
56
|
+
def foo(a, b=2)
|
57
|
+
a + b
|
58
|
+
end
|
59
|
+
|
60
|
+
def bar(word)
|
61
|
+
"You said #{word}!"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
env.add_udf(:foo)
|
66
|
+
CLIPS::Environment.add_udf(env, :bar)
|
67
|
+
```
|
68
|
+
|
69
|
+
#### `CLIPS::Environment.run` / `CLIPS::Environment#run`
|
70
|
+
|
71
|
+
Runs the rules engine, executing items on the agenda.
|
72
|
+
Optionally may take the number of items to run from the agenda as an argument.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
CLIPS::Environment.run(env, 1)
|
76
|
+
CLIPS::Environment.run(env)
|
77
|
+
env.run(1)
|
78
|
+
env.run
|
79
|
+
```
|
80
|
+
|
81
|
+
#### `CLIPS::Environment.clear` / `CLIPS::Environment#clear`
|
82
|
+
|
83
|
+
Removes constructs and data from the environment.
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
CLIPS::Environment.clear(env)
|
87
|
+
env.clear
|
88
|
+
```
|
89
|
+
|
90
|
+
#### `CLIPS::Environment.reset` / `CLIPS::Environment#reset`
|
91
|
+
|
92
|
+
Removes all facts and instances.
|
93
|
+
Creates facts and instances defined in deffacts and definstances constructs.
|
94
|
+
Resets the values of global variables in the specified environment.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
CLIPS::Environment.reset(env)
|
98
|
+
env.reset
|
99
|
+
```
|
100
|
+
|
101
|
+
#### `CLIPS::Environment.batch_star` / `env.batch_star`
|
33
102
|
|
34
103
|
Pass the path to a file that will be "batched" into the environment,
|
35
104
|
allowing many CLIPS commands to be entered at once.
|
@@ -39,8 +108,7 @@ CLIPS::Environment.batch_star(env, "./my-batch.bat")
|
|
39
108
|
env.batch_star("./my-batch.bat")
|
40
109
|
```
|
41
110
|
|
42
|
-
|
43
|
-
### `env.save`
|
111
|
+
#### `CLIPS::Environment.save` / `env.save`
|
44
112
|
|
45
113
|
Pass the path in which we'll save the environment constructs.
|
46
114
|
|
@@ -49,8 +117,7 @@ CLIPS::Environment.save(env, "./my-save.clp")
|
|
49
117
|
env.save("./my-save.clp")
|
50
118
|
```
|
51
119
|
|
52
|
-
|
53
|
-
### `env.load`
|
120
|
+
#### `CLIPS::Environment.load` / `env.load`
|
54
121
|
|
55
122
|
Pass the path to a file that will load the constructs stored in the file
|
56
123
|
into the environment. Remember to `reset` the environment if you need.
|
@@ -60,8 +127,7 @@ CLIPS::Environment.load(env, "./my-load.clp")
|
|
60
127
|
env.load("./my-load.clp")
|
61
128
|
```
|
62
129
|
|
63
|
-
|
64
|
-
### `env.save_facts`
|
130
|
+
#### `CLIPS::Environment.save_facts` / `env.save_facts`
|
65
131
|
|
66
132
|
Pass the path in which we'll save the environment facts.
|
67
133
|
The third argument is optional, and determines whether to store the visible or local facts.
|
@@ -76,8 +142,7 @@ CLIPS::Environment.save_facts(env, "./my-save-facts.clp", :visible)
|
|
76
142
|
env.save_facts("./my-save-facts.clp", :visible)
|
77
143
|
```
|
78
144
|
|
79
|
-
|
80
|
-
### `env.load_facts`
|
145
|
+
#### `CLIPS::Environment.load_facts` / `env.load_facts`
|
81
146
|
|
82
147
|
Pass the path to a file that will load the facts stored in the file
|
83
148
|
into the environment.
|
@@ -87,8 +152,32 @@ CLIPS::Environment.load_facts(env, "./my-load-facts.clp")
|
|
87
152
|
env.load_facts("./my-load-facts.clp")
|
88
153
|
```
|
89
154
|
|
90
|
-
|
91
|
-
|
155
|
+
#### `CLIPS::Environment.save_instances` / `env.save_instances`
|
156
|
+
|
157
|
+
Pass the path in which we'll save the environment instances.
|
158
|
+
The third argument is optional, and determines whether to store the visible or local instances.
|
159
|
+
By default, it'll store local.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
CLIPS::Environment.save_instances(env, "./my-save-instances.clp")
|
163
|
+
env.save_instances("./my-save-instances.clp")
|
164
|
+
CLIPS::Environment.save_instances(env, "./my-save-instances.clp", :local)
|
165
|
+
env.save_instances("./my-save-instances.clp", :local)
|
166
|
+
CLIPS::Environment.save_instances(env, "./my-save-instances.clp", :visible)
|
167
|
+
env.save_instances("./my-save-instances.clp", :visible)
|
168
|
+
```
|
169
|
+
|
170
|
+
#### `CLIPS::Environment.load_instances` / `env.load_instances`
|
171
|
+
|
172
|
+
Pass the path to a file that will load the instances stored in the file
|
173
|
+
into the environment.
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
CLIPS::Environment.load_instances(env, "./my-load-instances.clp")
|
177
|
+
env.load_instances("./my-load-instances.clp")
|
178
|
+
```
|
179
|
+
|
180
|
+
#### `CLIPS::Environment.bsave` / `env.bsave`
|
92
181
|
|
93
182
|
Pass the path in which we'll save the binary representation of the environment constructs.
|
94
183
|
|
@@ -97,8 +186,7 @@ CLIPS::Environment.bsave(env, "./my-bsave.bin")
|
|
97
186
|
env.bsave("./my-bsave.bin")
|
98
187
|
```
|
99
188
|
|
100
|
-
|
101
|
-
### `env.bload`
|
189
|
+
#### `CLIPS::Environment.bload` / `env.bload`
|
102
190
|
|
103
191
|
Pass the path to a binary file that will load the constructs stored in the file
|
104
192
|
into the environment. Remember to `reset` the environment if you need.
|
@@ -108,8 +196,7 @@ CLIPS::Environment.bload(env, "./my-bload.bin")
|
|
108
196
|
env.bload("./my-bload.bin")
|
109
197
|
```
|
110
198
|
|
111
|
-
|
112
|
-
### `env.bsave_facts`
|
199
|
+
#### `CLIPS::Environment.bsave_facts` / `env.bsave_facts`
|
113
200
|
|
114
201
|
Pass the path in which we'll save the binary representation of the environment facts.
|
115
202
|
The third argument is optional, and determines whether to store the visible or local facts.
|
@@ -124,8 +211,7 @@ CLIPS::Environment.bsave_facts(env, "./my-bsave-facts.bin", :visible)
|
|
124
211
|
env.bsave_facts("./my-bsave-facts.bin", :visible)
|
125
212
|
```
|
126
213
|
|
127
|
-
|
128
|
-
### `env.bload_facts`
|
214
|
+
#### `CLIPS::Environment.bload_facts` / `env.bload_facts`
|
129
215
|
|
130
216
|
Pass the path to a binary file that will load the facts stored in the file
|
131
217
|
into the environment.
|
@@ -135,8 +221,33 @@ CLIPS::Environment.bload_facts(env, "./my-bload-facts.bin")
|
|
135
221
|
env.bload_facts("./my-bload-facts.bin")
|
136
222
|
```
|
137
223
|
|
138
|
-
|
139
|
-
|
224
|
+
#### `CLIPS::Environment.bsave_instances` / `env.bsave_instances`
|
225
|
+
|
226
|
+
Pass the path in which we'll save the binary representation of the environment instances.
|
227
|
+
The third argument is optional, and determines whether to store the visible or local instances.
|
228
|
+
By default, it'll store local.
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
CLIPS::Environment.bsave_instances(env, "./my-bsave-instances.bin")
|
232
|
+
env.bsave_instances("./my-bsave-instances.bin")
|
233
|
+
CLIPS::Environment.bsave_instances(env, "./my-bsave-instances.bin", :local)
|
234
|
+
env.bsave_instances("./my-bsave-instances.bin", :local)
|
235
|
+
CLIPS::Environment.bsave_instances(env, "./my-bsave-instances.bin", :visible)
|
236
|
+
env.bsave_instances("./my-bsave-instances.bin", :visible)
|
237
|
+
```
|
238
|
+
|
239
|
+
#### `CLIPS::Environment.bload_facts` / `env.bload_facts`
|
240
|
+
|
241
|
+
Pass the path to a binary file that will load the facts stored in the file
|
242
|
+
into the environment.
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
CLIPS::Environment.bload_facts(env, "./my-bload-facts.bin")
|
246
|
+
env.bload_facts("./my-bload-facts.bin")
|
247
|
+
```
|
248
|
+
|
249
|
+
|
250
|
+
#### `CLIPS::Environment.assert_string` / `CLIPS::Environment#assert_string`
|
140
251
|
|
141
252
|
Assert a string as a Fact in the CLIPS environment.
|
142
253
|
|
@@ -145,8 +256,7 @@ fact = CLIPS::Environment.assert_string(env, "(foo bar)")
|
|
145
256
|
fact2 = env.assert_string("(bat baz)")
|
146
257
|
```
|
147
258
|
|
148
|
-
|
149
|
-
### `CLIPS::Environment#assert_hash`
|
259
|
+
#### `CLIPS::Environment.assert_hash` / `CLIPS::Environment#assert_hash`
|
150
260
|
|
151
261
|
Asserts a Deftemplate fact into the CLIPS environment
|
152
262
|
|
@@ -155,18 +265,42 @@ fact = CLIPS::Environment.assert_hash(env, :my_deftemplate, a: 1, b: "asdf", c:
|
|
155
265
|
fact2 = env.assert_hash(:my_deftemplate, d: 4.5, e: :asdf)
|
156
266
|
```
|
157
267
|
|
158
|
-
|
159
|
-
|
268
|
+
#### `CLIPS::Environment.make_instance` / `CLIPS::Environment#make_instance`
|
269
|
+
|
270
|
+
Make an Instance in the CLIPS environment.
|
271
|
+
|
272
|
+
The first argument can be:
|
273
|
+
|
274
|
+
* a symbol/string representing a string you'd call `make-instance` with in CLIPS code
|
275
|
+
* a symbol/string representing a Defclass in the environment
|
276
|
+
* a `CLIPS::Environment::Defclass` object
|
277
|
+
|
278
|
+
The second argument can be:
|
279
|
+
|
280
|
+
* a symbol/string representing the name of the instance you'd like
|
281
|
+
* a hash holding the key/value pairs for instance slot assignment
|
282
|
+
* `nil`
|
160
283
|
|
161
|
-
|
284
|
+
The third argument can be:
|
285
|
+
|
286
|
+
* a hash holding the key/value pairs for instance slot assignment
|
162
287
|
|
163
288
|
```ruby
|
164
289
|
instance = CLIPS::Environment.make_instance(env, "(of USER)")
|
165
290
|
instance2 = env.make_instance("(of USER)")
|
291
|
+
instance3 = CLIPS::Environment.make_instance(env, :USER)
|
292
|
+
instance4 = env.make_instance(:USER)
|
293
|
+
instance5 = CLIPS::Environment.make_instance(env, env.find_defclass(:USER))
|
294
|
+
instance6 = env.make_instance(env.find_defclass(:USER))
|
295
|
+
instance7 = CLIPS::Environment.make_instance(env, env.find_defclass(:my_class), foo: "Bar!")
|
296
|
+
instance8 = env.make_instance(env.find_defclass(:my_class), foo: "Bar!")
|
297
|
+
instance9 = CLIPS::Environment.make_instance(env, env.find_defclass(:my_class), :my_instance1, foo: "Bar!")
|
298
|
+
instance10 = env.make_instance(env.find_defclass(:my_class), :my_instance2, foo: "Bar.")
|
299
|
+
instance11 = CLIPS::Environment.make_instance(env, env.find_defclass(:my_class), nil, foo: "Bar?")
|
300
|
+
instance12 = env.make_instance(env.find_defclass(:my_class), nil, foo: "Bar...")
|
166
301
|
```
|
167
302
|
|
168
|
-
|
169
|
-
### `CLIPS::Environment#find_fact`
|
303
|
+
#### `CLIPS::Environment.find_fact` / `CLIPS::Environment#find_fact`
|
170
304
|
|
171
305
|
A light wrapper around the CLIPS find-fact function. Accepts a fact set template and query,
|
172
306
|
returns the first Facts in the environment that match as Ruby objects.
|
@@ -178,8 +312,7 @@ CLIPS::Environment.find_fact(env, "(?f my_deftemplate)", "(eq ?f:b \"asdf\")")
|
|
178
312
|
env.find_fact("(?f my_deftemplate)", "(= ?f:a 1)")
|
179
313
|
```
|
180
314
|
|
181
|
-
|
182
|
-
### `CLIPS::Environment#get_fact_list`
|
315
|
+
#### `CLIPS::Environment.get_fact_list` / `CLIPS::Environment#get_fact_list`
|
183
316
|
|
184
317
|
Return an array of Facts in the environment. Pass an argument of a
|
185
318
|
symbol, string, or Defmodule object in order to only get Facts with deftemplates
|
@@ -194,8 +327,7 @@ CLIPS::Environment.get_fact_list(defmodule)
|
|
194
327
|
env.get_fact_list(defmodule)
|
195
328
|
```
|
196
329
|
|
197
|
-
|
198
|
-
### `CLIPS::Environment#find_all_facts`
|
330
|
+
#### `CLIPS::Environment.find_all_facts` / `CLIPS::Environment#find_all_facts`
|
199
331
|
|
200
332
|
A light wrapper around the CLIPS find-all-facts function. Accepts a fact set template and query,
|
201
333
|
returns Facts in the environment that match as Ruby objects.
|
@@ -207,113 +339,197 @@ CLIPS::Environment.find_all_facts(env, "(?f my_deftemplate)", "(eq ?f:b \"asdf\"
|
|
207
339
|
env.find_all_facts("(?f my_deftemplate)", "(= ?f:a 1)")
|
208
340
|
```
|
209
341
|
|
210
|
-
|
211
|
-
### `CLIPS::Environment#_eval`
|
342
|
+
#### `CLIPS::Environment.facts` / `CLIPS::Environment#facts`
|
212
343
|
|
213
|
-
|
344
|
+
Print all Facts defined in the CLIPS environment
|
214
345
|
|
215
346
|
```ruby
|
216
|
-
CLIPS::Environment.
|
217
|
-
env.
|
347
|
+
CLIPS::Environment.facts(env)
|
348
|
+
env.facts
|
218
349
|
```
|
219
350
|
|
220
|
-
|
221
|
-
### `CLIPS::Environment#build`
|
351
|
+
#### `CLIPS::Environment.get_current_module` / `CLIPS::Environment#get_current_module`
|
222
352
|
|
223
|
-
|
353
|
+
Get the current module in the CLIPS environment
|
224
354
|
|
225
355
|
```ruby
|
226
|
-
CLIPS::Environment.
|
227
|
-
env.
|
356
|
+
CLIPS::Environment.get_current_module(env)
|
357
|
+
env.get_current_module
|
228
358
|
```
|
229
359
|
|
230
|
-
|
231
|
-
### `CLIPS::Environment#add_udf`
|
360
|
+
#### `CLIPS::Environment.set_current_module` / `CLIPS::Environment#set_current_module`
|
232
361
|
|
233
|
-
|
362
|
+
Set the current module in the CLIPS environment
|
234
363
|
|
235
364
|
```ruby
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
def bar(word)
|
242
|
-
"You said #{word}!"
|
243
|
-
end
|
244
|
-
end
|
365
|
+
CLIPS::Environment.set_current_module(env, defmodule)
|
366
|
+
env.set_current_module(defmodule)
|
367
|
+
```
|
245
368
|
|
246
|
-
|
247
|
-
|
369
|
+
#### `CLIPS::Environment.find_defrule` / `CLIPS::Environment#find_defrule`
|
370
|
+
|
371
|
+
Finds a defrule by name and returns a CLIPS::Environment::Defrule object
|
372
|
+
|
373
|
+
```ruby
|
374
|
+
CLIPS::Environment.find_defrule(:a)
|
375
|
+
env.find_defrule("foo")
|
248
376
|
```
|
249
377
|
|
250
|
-
|
251
|
-
### `CLIPS::Environment#run`
|
378
|
+
#### `CLIPS::Environment.find_instance` / `CLIPS::Environment#find_instance`
|
252
379
|
|
253
|
-
|
254
|
-
|
380
|
+
Finds an instance by name and returns a CLIPS::Environment::Instance object.
|
381
|
+
Can take an optional second and third argument for Defmodule or Demodule name
|
382
|
+
and a boolean that represents whether or not the instance should be searched for
|
383
|
+
in imported modules.
|
384
|
+
If the second argument is `nil`, `find_instance` will search the current module only.
|
255
385
|
|
256
386
|
```ruby
|
257
|
-
CLIPS::Environment.
|
258
|
-
|
259
|
-
|
260
|
-
env.
|
387
|
+
CLIPS::Environment.find_definstance(:a)
|
388
|
+
env.find_definstance("foo")
|
389
|
+
CLIPS::Environment.find_definstance(:a, :my_module)
|
390
|
+
env.find_definstance("foo", "my_module")
|
391
|
+
CLIPS::Environment.find_definstance(:a, :my_module, true)
|
392
|
+
env.find_definstance("foo", nil, true)
|
261
393
|
```
|
262
394
|
|
263
|
-
|
264
|
-
### `CLIPS::Environment#clear`
|
395
|
+
#### `CLIPS::Environment.find_defmodule` / `CLIPS::Environment#find_defmodule`
|
265
396
|
|
266
|
-
|
397
|
+
Finds a defmodule by name and returns a CLIPS::Environment::Defmodule object
|
267
398
|
|
268
399
|
```ruby
|
269
|
-
CLIPS::Environment.
|
270
|
-
env.
|
400
|
+
CLIPS::Environment.find_defmodule(:a)
|
401
|
+
env.find_defmodule("foo")
|
271
402
|
```
|
272
403
|
|
273
|
-
|
274
|
-
### `CLIPS::Environment#reset`
|
404
|
+
#### `CLIPS::Environment.get_defclass_list` / `CLIPS::Environment#get_defclass_list`
|
275
405
|
|
276
|
-
|
277
|
-
|
278
|
-
|
406
|
+
Return an array of Defclass names as symbols in the environment. Pass an argument of a
|
407
|
+
symbol, string, or Defmodule object in order to only get Defclasss
|
408
|
+
in that Defmodule. If you do not, it will return all Defclass names in all modules.
|
279
409
|
|
280
410
|
```ruby
|
281
|
-
CLIPS::Environment.
|
282
|
-
env.
|
411
|
+
CLIPS::Environment.get_defclass_list(env)
|
412
|
+
env.get_defclass_list
|
413
|
+
CLIPS::Environment.get_defclass_list(env, :MAIN)
|
414
|
+
env.get_defclass_list(:MAIN)
|
415
|
+
CLIPS::Environment.get_defclass_list(env, defmodule)
|
416
|
+
env.get_defclass_list(defmodule)
|
283
417
|
```
|
284
418
|
|
285
|
-
|
286
|
-
### `CLIPS::Environment#facts`
|
419
|
+
#### `CLIPS::Environment.get_instance_list` / `CLIPS::Environment#get_instance_list`
|
287
420
|
|
288
|
-
|
421
|
+
Return an array of Instances in the environment. Pass an argument of a
|
422
|
+
symbol, string, or Defclass object in order to only get Instances
|
423
|
+
in that Defclass. If you do not, it will return all Instances of all Defclasses.
|
424
|
+
If you do, you may also pass `true` as the second argument
|
425
|
+
to include instances of subclasses of this Defclass.
|
289
426
|
|
290
427
|
```ruby
|
291
|
-
CLIPS::Environment.
|
292
|
-
env.
|
428
|
+
CLIPS::Environment.get_instance_list(env)
|
429
|
+
env.get_instance_list
|
430
|
+
CLIPS::Environment.get_instance_list(env, :foo_class)
|
431
|
+
env.get_instance_list(:"my-class")
|
432
|
+
CLIPS::Environment.get_instance_list(env, defclass)
|
433
|
+
env.get_instance_list(defclass)
|
434
|
+
CLIPS::Environment.get_instance_list(env, defclass, true)
|
435
|
+
env.get_instance_list(defclass, true)
|
293
436
|
```
|
294
437
|
|
295
|
-
|
296
|
-
### `CLIPS::Environment#get_current_module`
|
438
|
+
#### `CLIPS::Environment.get_deftemplate_list` / `CLIPS::Environment#get_deftemplate_list`
|
297
439
|
|
298
|
-
|
440
|
+
Return an array of Deftemplate names as symbols in the environment. Pass an argument of a
|
441
|
+
symbol, string, or Defmodule object in order to only get Deftemplates
|
442
|
+
in that Defmodule. If you do not, it will return all Deftemplate names in all modules.
|
299
443
|
|
300
444
|
```ruby
|
301
|
-
CLIPS::Environment.
|
302
|
-
env.
|
445
|
+
CLIPS::Environment.get_deftemplate_list(env)
|
446
|
+
env.get_deftemplate_list
|
447
|
+
CLIPS::Environment.get_deftemplate_list(env, :MAIN)
|
448
|
+
env.get_deftemplate_list(:MAIN)
|
449
|
+
CLIPS::Environment.get_deftemplate_list(env, defmodule)
|
450
|
+
env.get_deftemplate_list(defmodule)
|
303
451
|
```
|
304
452
|
|
305
|
-
|
306
|
-
### `CLIPS::Environment#set_current_module`
|
453
|
+
#### `CLIPS::Environment.get_defrule_list` / `CLIPS::Environment#get_defrule_list`
|
307
454
|
|
308
|
-
|
455
|
+
Return an array of Defrule names as symbols in the environment. Pass an argument of a
|
456
|
+
symbol, string, or Defmodule object in order to only get Defrules
|
457
|
+
in that Defmodule. If you do not, it will return all Defrule names in all modules.
|
309
458
|
|
310
459
|
```ruby
|
311
|
-
CLIPS::Environment.
|
312
|
-
env.
|
460
|
+
CLIPS::Environment.get_defrule_list(env)
|
461
|
+
env.get_defrule_list
|
462
|
+
CLIPS::Environment.get_defrule_list(env, :MAIN)
|
463
|
+
env.get_defrule_list(:MAIN)
|
464
|
+
CLIPS::Environment.get_defrule_list(env, defmodule)
|
465
|
+
env.get_defrule_list(defmodule)
|
313
466
|
```
|
314
467
|
|
315
|
-
|
316
|
-
|
468
|
+
#### `CLIPS::Environment.get_defmodule_list` / `CLIPS::Environment#get_defmodule_list`
|
469
|
+
|
470
|
+
Return an array of Defmodule names as symbols in the environment.
|
471
|
+
|
472
|
+
```ruby
|
473
|
+
CLIPS::Environment.get_defmodule_list(env)
|
474
|
+
env.get_defmodule_list
|
475
|
+
```
|
476
|
+
|
477
|
+
#### `CLIPS::Environment.find_deftemplate` / `CLIPS::Environment#find_deftemplate`
|
478
|
+
|
479
|
+
Finds a deftemplate by name and returns a CLIPS::Environment::Deftemplate object
|
480
|
+
|
481
|
+
```ruby
|
482
|
+
CLIPS::Environment.find_deftemplate(:a)
|
483
|
+
env.find_deftemplate("foo")
|
484
|
+
```
|
485
|
+
|
486
|
+
#### `CLIPS::Environment.find_defclass` / `CLIPS::Environment#find_defclass`
|
487
|
+
|
488
|
+
Finds a defclass by name and returns a CLIPS::Environment::Defclass object
|
489
|
+
|
490
|
+
```ruby
|
491
|
+
CLIPS::Environment.find_defclass(:a)
|
492
|
+
env.find_defclass("foo")
|
493
|
+
```
|
494
|
+
|
495
|
+
#### `CLIPS::Environment.watch` / `env.watch`
|
496
|
+
#### `CLIPS::Environment.unwatch` / `env.unwatch`
|
497
|
+
|
498
|
+
"Watch" or "Unwatch" a specific thing that happens in the CLIPS environment.
|
499
|
+
There are several things that may be watched (or unwatched) such that CLIPS will
|
500
|
+
report debugging information to `STDOUT`. This gem provides two ways to watch
|
501
|
+
or unwatch a debug item: either pass the watch item as a symbol to `watch` or
|
502
|
+
`unwatch`, or use the corresponding `watch_foo` or `unwatch_foo` methods where
|
503
|
+
`foo` is replaced by the watch item (as listed):
|
504
|
+
|
505
|
+
```ruby
|
506
|
+
:all
|
507
|
+
:facts
|
508
|
+
:instances
|
509
|
+
:slots
|
510
|
+
:rules
|
511
|
+
:activations
|
512
|
+
:messages
|
513
|
+
:message_handlers
|
514
|
+
:generic_functions
|
515
|
+
:methods
|
516
|
+
:deffunctions
|
517
|
+
:compilations
|
518
|
+
:statistics
|
519
|
+
:globals
|
520
|
+
:focus
|
521
|
+
```
|
522
|
+
|
523
|
+
```ruby
|
524
|
+
CLIPS::Environment.watch_facts
|
525
|
+
env.watch_statistics
|
526
|
+
CLIPS::Environment.unwatch(:facts)
|
527
|
+
env.unwatch(:statistics)
|
528
|
+
```
|
529
|
+
|
530
|
+
### Fact Methods
|
531
|
+
|
532
|
+
#### `CLIPS::Environment::Fact.pp_form` / `CLIPS::Environment::Fact#pp_form`
|
317
533
|
|
318
534
|
Returns a pretty printed string representation of the Fact
|
319
535
|
|
@@ -322,8 +538,7 @@ CLIPS::Environment::Fact.pp_form(fact)
|
|
322
538
|
fact.pp_form
|
323
539
|
```
|
324
540
|
|
325
|
-
|
326
|
-
### `CLIPS::Environment::Fact#existp`
|
541
|
+
#### `CLIPS::Environment::Fact.existp` / `CLIPS::Environment::Fact#existp`
|
327
542
|
|
328
543
|
Returns a boolean representing whether or not a Fact has been retracted
|
329
544
|
|
@@ -332,8 +547,7 @@ CLIPS::Environment::Fact.existp(fact)
|
|
332
547
|
fact.existp
|
333
548
|
```
|
334
549
|
|
335
|
-
|
336
|
-
### `CLIPS::Environment::Fact#to_h`
|
550
|
+
#### `CLIPS::Environment::Fact.to_h` / `CLIPS::Environment::Fact#to_h`
|
337
551
|
|
338
552
|
Returns a hash representing the fact slot names and their values
|
339
553
|
|
@@ -342,8 +556,7 @@ CLIPS::Environment::Fact.to_h(fact)
|
|
342
556
|
fact.to_h
|
343
557
|
```
|
344
558
|
|
345
|
-
|
346
|
-
### `CLIPS::Environment::Fact#index`
|
559
|
+
#### `CLIPS::Environment::Fact.index` / `CLIPS::Environment::Fact#index`
|
347
560
|
|
348
561
|
Returns the index of the fact in working memory
|
349
562
|
|
@@ -352,8 +565,7 @@ CLIPS::Environment::Fact.index(fact)
|
|
352
565
|
fact.index
|
353
566
|
```
|
354
567
|
|
355
|
-
|
356
|
-
### `CLIPS::Environment::Fact#deftemplate`
|
568
|
+
#### `CLIPS::Environment::Fact.deftemplate` / `CLIPS::Environment::Fact#deftemplate`
|
357
569
|
|
358
570
|
Returns the Deftemplate object for a fact
|
359
571
|
|
@@ -362,8 +574,7 @@ CLIPS::Environment::Fact.deftemplate(fact)
|
|
362
574
|
fact.deftemplate
|
363
575
|
```
|
364
576
|
|
365
|
-
|
366
|
-
### `CLIPS::Environment::Fact#deftemplate_name`
|
577
|
+
#### `CLIPS::Environment::Fact.deftemplate_name` / `CLIPS::Environment::Fact#deftemplate_name`
|
367
578
|
|
368
579
|
Returns the name of the Deftemplate for a fact as a symbol
|
369
580
|
|
@@ -372,8 +583,7 @@ CLIPS::Environment::Fact.deftemplate_name(fact)
|
|
372
583
|
fact.deftemplate_name
|
373
584
|
```
|
374
585
|
|
375
|
-
|
376
|
-
### `CLIPS::Environment::Fact#slot_names`
|
586
|
+
#### `CLIPS::Environment::Fact.slot_names` / `CLIPS::Environment::Fact#slot_names`
|
377
587
|
|
378
588
|
Returns an array representing the slot names of a fact
|
379
589
|
|
@@ -382,8 +592,7 @@ CLIPS::Environment::Fact.slot_names(fact)
|
|
382
592
|
fact.slot_names
|
383
593
|
```
|
384
594
|
|
385
|
-
|
386
|
-
### `CLIPS::Environment::Fact#get_slot`
|
595
|
+
#### `CLIPS::Environment::Fact.get_slot` / `CLIPS::Environment::Fact#get_slot`
|
387
596
|
|
388
597
|
Gets the value stored in the specified slot of a fact.
|
389
598
|
Can either pass a string or symbol for the slot name argument.
|
@@ -393,8 +602,7 @@ CLIPS::Environment::Fact.get_slot(fact, 'bar')
|
|
393
602
|
fact.get_slot(:foo)
|
394
603
|
```
|
395
604
|
|
396
|
-
|
397
|
-
### `CLIPS::Environment::Fact#retract`
|
605
|
+
#### `CLIPS::Environment::Fact.retract` / `CLIPS::Environment::Fact#retract`
|
398
606
|
|
399
607
|
Retracts a fact from the environment.
|
400
608
|
|
@@ -403,8 +611,7 @@ CLIPS::Environment::Fact.retract(fact)
|
|
403
611
|
fact.retract
|
404
612
|
```
|
405
613
|
|
406
|
-
|
407
|
-
### `CLIPS::Environment::Fact#modify`
|
614
|
+
#### `CLIPS::Environment::Fact.modify` / `CLIPS::Environment::Fact#modify`
|
408
615
|
|
409
616
|
Modifies a non-implicit deftemplate fact from the environment.
|
410
617
|
Will not work with non-deftemplate facts!
|
@@ -414,8 +621,9 @@ CLIPS::Environment::Fact.modify(fact, bar: 123)
|
|
414
621
|
fact.modify(foo: "my new foo!")
|
415
622
|
```
|
416
623
|
|
417
|
-
###
|
418
|
-
|
624
|
+
### Instance Methods
|
625
|
+
|
626
|
+
#### `CLIPS::Environment::Instance.unmake` / `CLIPS::Environment::Instance#unmake`
|
419
627
|
|
420
628
|
Unmakes an instance in the environment, deleting it.
|
421
629
|
|
@@ -424,8 +632,7 @@ CLIPS::Environment::Instance.unmake(instance)
|
|
424
632
|
instance.unmake
|
425
633
|
```
|
426
634
|
|
427
|
-
|
428
|
-
### `CLIPS::Environment::Instance#delete`
|
635
|
+
#### `CLIPS::Environment::Instance.delete` / `CLIPS::Environment::Instance#delete`
|
429
636
|
|
430
637
|
Deletes an instance in the environment.
|
431
638
|
|
@@ -434,8 +641,7 @@ CLIPS::Environment::Instance.delete(instance)
|
|
434
641
|
instance.delete
|
435
642
|
```
|
436
643
|
|
437
|
-
|
438
|
-
### `CLIPS::Environment::Instance#name`
|
644
|
+
#### `CLIPS::Environment::Instance.name` / `CLIPS::Environment::Instance#name`
|
439
645
|
|
440
646
|
Returns the name of an Instance as a symbol
|
441
647
|
|
@@ -444,8 +650,7 @@ CLIPS::Environment::Instance.name(instance)
|
|
444
650
|
instance.name
|
445
651
|
```
|
446
652
|
|
447
|
-
|
448
|
-
### `CLIPS::Environment::Instance#pp_form`
|
653
|
+
#### `CLIPS::Environment::Instance.pp_form` / `CLIPS::Environment::Instance#pp_form`
|
449
654
|
|
450
655
|
Returns a pretty printed string representation of an Instance
|
451
656
|
|
@@ -454,8 +659,7 @@ CLIPS::Environment::Instance.pp_form(instance)
|
|
454
659
|
instance.pp_form
|
455
660
|
```
|
456
661
|
|
457
|
-
|
458
|
-
### `CLIPS::Environment::Instance#defclass`
|
662
|
+
#### `CLIPS::Environment::Instance.defclass` / `CLIPS::Environment::Instance#defclass`
|
459
663
|
|
460
664
|
Returns the Defclass of an Instance
|
461
665
|
|
@@ -464,8 +668,7 @@ CLIPS::Environment::Instance.defclass(instance)
|
|
464
668
|
instance.defclass
|
465
669
|
```
|
466
670
|
|
467
|
-
|
468
|
-
### `CLIPS::Environment::Instance#to_h`
|
671
|
+
#### `CLIPS::Environment::Instance.to_h` / `CLIPS::Environment::Instance#to_h`
|
469
672
|
|
470
673
|
Returns a hash representing the instance slot names and their values.
|
471
674
|
Pass a `true` as an argument to get inhereted slots as well.
|
@@ -477,8 +680,9 @@ CLIPS::Environment::Instance.to_h(instance, true)
|
|
477
680
|
instance.to_h(true)
|
478
681
|
```
|
479
682
|
|
480
|
-
###
|
481
|
-
|
683
|
+
### Defclass Methods
|
684
|
+
|
685
|
+
#### `CLIPS::Environment::Defclass.name` / `CLIPS::Environment::Defclass#name`
|
482
686
|
|
483
687
|
Returns the name of an Defclass as a symbol
|
484
688
|
|
@@ -487,8 +691,7 @@ CLIPS::Environment::Defclass.name(defclass)
|
|
487
691
|
defclass.name
|
488
692
|
```
|
489
693
|
|
490
|
-
|
491
|
-
### `CLIPS::Environment::Defclass#pp_form`
|
694
|
+
#### `CLIPS::Environment::Defclass.pp_form` / `CLIPS::Environment::Defclass#pp_form`
|
492
695
|
|
493
696
|
Returns a pretty printed string representation of an Defclass
|
494
697
|
|
@@ -497,8 +700,7 @@ CLIPS::Environment::Defclass.pp_form(defclass)
|
|
497
700
|
defclass.pp_form
|
498
701
|
```
|
499
702
|
|
500
|
-
|
501
|
-
### `CLIPS::Environment::Defclass#slots`
|
703
|
+
#### `CLIPS::Environment::Defclass.slots` / `CLIPS::Environment::Defclass#slots`
|
502
704
|
|
503
705
|
Returns an array representing the slot names of a Defclass.
|
504
706
|
Pass `true` as an argument to get inherited slots, as well.
|
@@ -510,8 +712,7 @@ CLIPS::Environment::Defclass.slots(defclass, true)
|
|
510
712
|
defclass.slots(true)
|
511
713
|
```
|
512
714
|
|
513
|
-
|
514
|
-
### `CLIPS::Environment::Defclass#defmodule_name`
|
715
|
+
#### `CLIPS::Environment::Defclass.defmodule_name` / `CLIPS::Environment::Defclass#defmodule_name`
|
515
716
|
|
516
717
|
Returns the name of the defmodule in which the defclass is defined
|
517
718
|
|
@@ -520,8 +721,7 @@ CLIPS::Environment::Defclass.defmodule_name(defclass)
|
|
520
721
|
defclass.defmodule_name
|
521
722
|
```
|
522
723
|
|
523
|
-
|
524
|
-
### `CLIPS::Environment::Defclass#defmodule`
|
724
|
+
#### `CLIPS::Environment::Defclass.defmodule` / `CLIPS::Environment::Defclass#defmodule`
|
525
725
|
|
526
726
|
Returns the defmodule in which the defclass is defined
|
527
727
|
|
@@ -530,8 +730,7 @@ CLIPS::Environment::Defclass.defmodule(defclass)
|
|
530
730
|
defclass.defmodule
|
531
731
|
```
|
532
732
|
|
533
|
-
|
534
|
-
### `CLIPS::Environment::Defclass#get_instance_list`
|
733
|
+
#### `CLIPS::Environment::Defclass.get_instance_list` / `CLIPS::Environment::Defclass#get_instance_list`
|
535
734
|
|
536
735
|
Return an array of Instances of the Defclass.
|
537
736
|
Pass `true` as an argument to include instances of subclasses
|
@@ -544,8 +743,7 @@ defclass.get_instance_list
|
|
544
743
|
defclass.get_instance_list(true)
|
545
744
|
```
|
546
745
|
|
547
|
-
|
548
|
-
### `CLIPS::Environment::Defclass#superclasses`
|
746
|
+
#### `CLIPS::Environment::Defclass.superclasses` / `CLIPS::Environment::Defclass#superclasses`
|
549
747
|
|
550
748
|
Return an array of superclasses of the Defclass.
|
551
749
|
Pass `true` as an argument to include inherited superclasses.
|
@@ -557,8 +755,7 @@ defclass.superclasses
|
|
557
755
|
defclass.superclasses(true)
|
558
756
|
```
|
559
757
|
|
560
|
-
|
561
|
-
### `CLIPS::Environment::Defclass#subclasses`
|
758
|
+
#### `CLIPS::Environment::Defclass.subclasses` / `CLIPS::Environment::Defclass#subclasses`
|
562
759
|
|
563
760
|
Return an array of subclasses of the Defclass.
|
564
761
|
Pass `true` as an argument to include inherited subclasses.
|
@@ -570,36 +767,9 @@ defclass.subclasses
|
|
570
767
|
defclass.subclasses(true)
|
571
768
|
```
|
572
769
|
|
573
|
-
###
|
574
|
-
### `CLIPS::Environment#find_defrule`
|
575
|
-
|
576
|
-
Finds a defrule by name and returns a CLIPS::Environment::Defrule object
|
577
|
-
|
578
|
-
```ruby
|
579
|
-
CLIPS::Environment.find_defrule(:a)
|
580
|
-
env.find_defrule("foo")
|
581
|
-
```
|
582
|
-
|
583
|
-
### `CLIPS::Environment.find_instance`
|
584
|
-
### `CLIPS::Environment#find_instance`
|
585
|
-
|
586
|
-
Finds an instance by name and returns a CLIPS::Environment::Instance object.
|
587
|
-
Can take an optional second and third argument for Defmodule or Demodule name
|
588
|
-
and a boolean that represents whether or not the instance should be searched for
|
589
|
-
in imported modules.
|
590
|
-
If the second argument is `nil`, `find_instance` will search the current module only.
|
591
|
-
|
592
|
-
```ruby
|
593
|
-
CLIPS::Environment.find_definstance(:a)
|
594
|
-
env.find_definstance("foo")
|
595
|
-
CLIPS::Environment.find_definstance(:a, :my_module)
|
596
|
-
env.find_definstance("foo", "my_module")
|
597
|
-
CLIPS::Environment.find_definstance(:a, :my_module, true)
|
598
|
-
env.find_definstance("foo", nil, true)
|
599
|
-
```
|
770
|
+
### Defrule Methods
|
600
771
|
|
601
|
-
|
602
|
-
### `CLIPS::Environment::Defrule#name`
|
772
|
+
#### `CLIPS::Environment::Defrule.name` / `CLIPS::Environment::Defrule#name`
|
603
773
|
|
604
774
|
Returns the name of a defrule as a symbol
|
605
775
|
|
@@ -608,8 +778,7 @@ CLIPS::Environment::Defrule.name(defrule)
|
|
608
778
|
defrule.name
|
609
779
|
```
|
610
780
|
|
611
|
-
|
612
|
-
### `CLIPS::Environment::Defrule#defmodule_name`
|
781
|
+
#### `CLIPS::Environment::Defrule.defmodule_name` / `CLIPS::Environment::Defrule#defmodule_name`
|
613
782
|
|
614
783
|
Returns the name of the defmodule in which the defrule is defined
|
615
784
|
|
@@ -618,8 +787,7 @@ CLIPS::Environment::Defrule.defmodule_name(defrule)
|
|
618
787
|
defrule.defmodule_name
|
619
788
|
```
|
620
789
|
|
621
|
-
|
622
|
-
### `CLIPS::Environment::Defrule#defmodule`
|
790
|
+
#### `CLIPS::Environment::Defrule.defmodule` / `CLIPS::Environment::Defrule#defmodule`
|
623
791
|
|
624
792
|
Returns the defmodule in which the defrule is defined
|
625
793
|
|
@@ -628,8 +796,7 @@ CLIPS::Environment::Defrule.defmodule(defrule)
|
|
628
796
|
defrule.defmodule
|
629
797
|
```
|
630
798
|
|
631
|
-
|
632
|
-
### `CLIPS::Environment::Defrule#is_deletable`
|
799
|
+
#### `CLIPS::Environment::Defrule.is_deletable` / `CLIPS::Environment::Defrule#is_deletable`
|
633
800
|
|
634
801
|
Returns a boolean whether the Defrule is deletable or not
|
635
802
|
|
@@ -638,8 +805,7 @@ CLIPS::Environment::Defrule.is_deletable(defrule)
|
|
638
805
|
defrule.is_deletable
|
639
806
|
```
|
640
807
|
|
641
|
-
|
642
|
-
### `CLIPS::Environment::Defrule#pp_form`
|
808
|
+
#### `CLIPS::Environment::Defrule.pp_form` / `CLIPS::Environment::Defrule#pp_form`
|
643
809
|
|
644
810
|
Returns a pretty printed string representation of the Defrule
|
645
811
|
|
@@ -648,8 +814,7 @@ CLIPS::Environment::Defrule.pp_form(defrule)
|
|
648
814
|
defrule.pp_form
|
649
815
|
```
|
650
816
|
|
651
|
-
|
652
|
-
### `CLIPS::Environment::Defrule#has_breakpoint`
|
817
|
+
#### `CLIPS::Environment::Defrule.has_breakpoint` / `CLIPS::Environment::Defrule#has_breakpoint`
|
653
818
|
|
654
819
|
Returns whether or not the rule has a breakpoint set
|
655
820
|
|
@@ -658,8 +823,7 @@ CLIPS::Environment::Defrule.has_breakpoint(defrule)
|
|
658
823
|
defrule.has_breakpoint
|
659
824
|
```
|
660
825
|
|
661
|
-
|
662
|
-
### `CLIPS::Environment::Defrule#set_break`
|
826
|
+
#### `CLIPS::Environment::Defrule.set_break` / `CLIPS::Environment::Defrule#set_break`
|
663
827
|
|
664
828
|
Sets a breakpoint on a rule
|
665
829
|
|
@@ -668,8 +832,7 @@ CLIPS::Environment::Defrule.set_break(defrule)
|
|
668
832
|
defrule.set_break
|
669
833
|
```
|
670
834
|
|
671
|
-
|
672
|
-
### `CLIPS::Environment::Defrule#remove_break`
|
835
|
+
#### `CLIPS::Environment::Defrule.remove_break` / `CLIPS::Environment::Defrule#remove_break`
|
673
836
|
|
674
837
|
Returns whether or not it was able to remove a breakpoint from a rule
|
675
838
|
|
@@ -678,8 +841,7 @@ CLIPS::Environment::Defrule.remove_break(defrule)
|
|
678
841
|
defrule.remove_break
|
679
842
|
```
|
680
843
|
|
681
|
-
|
682
|
-
### `CLIPS::Environment::Defrule#salience`
|
844
|
+
#### `CLIPS::Environment::Defrule.salience` / `CLIPS::Environment::Defrule#salience`
|
683
845
|
|
684
846
|
Returns the salience of a defrule
|
685
847
|
|
@@ -688,18 +850,9 @@ CLIPS::Environment::Defrule.salience(defrule)
|
|
688
850
|
defrule.salience
|
689
851
|
```
|
690
852
|
|
691
|
-
###
|
692
|
-
### `CLIPS::Environment#find_defmodule`
|
693
|
-
|
694
|
-
Finds a defmodule by name and returns a CLIPS::Environment::Defmodule object
|
695
|
-
|
696
|
-
```ruby
|
697
|
-
CLIPS::Environment.find_defmodule(:a)
|
698
|
-
env.find_defmodule("foo")
|
699
|
-
```
|
853
|
+
### Defmodule Methods
|
700
854
|
|
701
|
-
|
702
|
-
### `CLIPS::Environment::Defmodule#name`
|
855
|
+
#### `CLIPS::Environment::Defmodule.name` / `CLIPS::Environment::Defmodule#name`
|
703
856
|
|
704
857
|
Returns the name of a defmodule as a symbol
|
705
858
|
|
@@ -708,8 +861,7 @@ CLIPS::Environment::Defmodule.name(defmodule)
|
|
708
861
|
defmodule.name
|
709
862
|
```
|
710
863
|
|
711
|
-
|
712
|
-
### `CLIPS::Environment::Defmodule#pp_form`
|
864
|
+
#### `CLIPS::Environment::Defmodule.pp_form` / `CLIPS::Environment::Defmodule#pp_form`
|
713
865
|
|
714
866
|
Returns a pretty printed string representation of the Defmodule
|
715
867
|
|
@@ -718,8 +870,7 @@ CLIPS::Environment::Defmodule.pp_form(defmodule)
|
|
718
870
|
defmodule.pp_form
|
719
871
|
```
|
720
872
|
|
721
|
-
|
722
|
-
### `CLIPS::Environment::Defmodule#set_current`
|
873
|
+
#### `CLIPS::Environment::Defmodule.set_current` / `CLIPS::Environment::Defmodule#set_current`
|
723
874
|
|
724
875
|
Sets the Defmodule as the current module of the environment
|
725
876
|
|
@@ -728,8 +879,7 @@ CLIPS::Environment::Defmodule.set_current(defmodule)
|
|
728
879
|
defmodule.set_current
|
729
880
|
```
|
730
881
|
|
731
|
-
|
732
|
-
### `CLIPS::Environment::Defmodule#get_fact_list`
|
882
|
+
#### `CLIPS::Environment::Defmodule.get_fact_list` / `CLIPS::Environment::Defmodule#get_fact_list`
|
733
883
|
|
734
884
|
Return an array of Facts with deftemplates in the Defmodule
|
735
885
|
|
@@ -738,8 +888,7 @@ CLIPS::Environment::Defmodule.get_fact_list(defmodule)
|
|
738
888
|
defmodule.get_fact_list
|
739
889
|
```
|
740
890
|
|
741
|
-
|
742
|
-
### `CLIPS::Environment::Defmodule#find_instance`
|
891
|
+
#### `CLIPS::Environment::Defmodule.find_instance` / `CLIPS::Environment::Defmodule#find_instance`
|
743
892
|
|
744
893
|
Finds an instance by name and returns a CLIPS::Environment::Instance object.
|
745
894
|
Can take an optional second argument
|
@@ -753,106 +902,36 @@ CLIPS::Environment::Defmodule.find_instance(:a, true)
|
|
753
902
|
defmodule.find_instance("foo", true)
|
754
903
|
```
|
755
904
|
|
756
|
-
|
757
|
-
### `CLIPS::Environment#get_defclass_list`
|
758
|
-
|
759
|
-
Return an array of Defclass names as symbols in the environment. Pass an argument of a
|
760
|
-
symbol, string, or Defmodule object in order to only get Defclasss
|
761
|
-
in that Defmodule. If you do not, it will return all Defclass names in all modules.
|
762
|
-
|
763
|
-
```ruby
|
764
|
-
CLIPS::Environment.get_defclass_list(env)
|
765
|
-
env.get_defclass_list
|
766
|
-
CLIPS::Environment.get_defclass_list(env, :MAIN)
|
767
|
-
env.get_defclass_list(:MAIN)
|
768
|
-
CLIPS::Environment.get_defclass_list(env, defmodule)
|
769
|
-
env.get_defclass_list(defmodule)
|
770
|
-
```
|
771
|
-
|
772
|
-
### `CLIPS::Environment.get_instance_list`
|
773
|
-
### `CLIPS::Environment#get_instance_list`
|
774
|
-
|
775
|
-
Return an array of Instances in the environment. Pass an argument of a
|
776
|
-
symbol, string, or Defclass object in order to only get Instances
|
777
|
-
in that Defclass. If you do not, it will return all Instances of all Defclasses.
|
778
|
-
If you do, you may also pass `true` as the second argument
|
779
|
-
to include instances of subclasses of this Defclass.
|
780
|
-
|
781
|
-
```ruby
|
782
|
-
CLIPS::Environment.get_instance_list(env)
|
783
|
-
env.get_instance_list
|
784
|
-
CLIPS::Environment.get_instance_list(env, :foo_class)
|
785
|
-
env.get_instance_list(:"my-class")
|
786
|
-
CLIPS::Environment.get_instance_list(env, defclass)
|
787
|
-
env.get_instance_list(defclass)
|
788
|
-
CLIPS::Environment.get_instance_list(env, defclass, true)
|
789
|
-
env.get_instance_list(defclass, true)
|
790
|
-
```
|
905
|
+
#### `CLIPS::Environment::Defmodule.get_defclass_list` / `CLIPS::Environment::Defmodule#get_defclass_list`
|
791
906
|
|
792
|
-
|
793
|
-
### `CLIPS::Environment#get_deftemplate_list`
|
794
|
-
|
795
|
-
Return an array of Deftemplate names as symbols in the environment. Pass an argument of a
|
796
|
-
symbol, string, or Defmodule object in order to only get Deftemplates
|
797
|
-
in that Defmodule. If you do not, it will return all Deftemplate names in all modules.
|
798
|
-
|
799
|
-
```ruby
|
800
|
-
CLIPS::Environment.get_deftemplate_list(env)
|
801
|
-
env.get_deftemplate_list
|
802
|
-
CLIPS::Environment.get_deftemplate_list(env, :MAIN)
|
803
|
-
env.get_deftemplate_list(:MAIN)
|
804
|
-
CLIPS::Environment.get_deftemplate_list(env, defmodule)
|
805
|
-
env.get_deftemplate_list(defmodule)
|
806
|
-
```
|
807
|
-
|
808
|
-
### `CLIPS::Environment.get_defrule_list`
|
809
|
-
### `CLIPS::Environment#get_defrule_list`
|
810
|
-
|
811
|
-
Return an array of Defrule names as symbols in the environment. Pass an argument of a
|
812
|
-
symbol, string, or Defmodule object in order to only get Defrules
|
813
|
-
in that Defmodule. If you do not, it will return all Defrule names in all modules.
|
907
|
+
Return an array of Defclass names as symbols in the Defmodule
|
814
908
|
|
815
909
|
```ruby
|
816
|
-
CLIPS::Environment.
|
817
|
-
|
818
|
-
CLIPS::Environment.get_defrule_list(env, :MAIN)
|
819
|
-
env.get_defrule_list(:MAIN)
|
820
|
-
CLIPS::Environment.get_defrule_list(env, defmodule)
|
821
|
-
env.get_defrule_list(defmodule)
|
910
|
+
CLIPS::Environment::Defmodule.get_defclass_list(defmodule)
|
911
|
+
defmodule.get_defclass_list
|
822
912
|
```
|
823
913
|
|
824
|
-
|
825
|
-
### `CLIPS::Environment#get_defmodule_list`
|
914
|
+
#### `CLIPS::Environment::Defmodule.get_deftemplate_list` / `CLIPS::Environment::Defmodule#get_deftemplate_list`
|
826
915
|
|
827
|
-
Return an array of
|
916
|
+
Return an array of Deftemplate names as symbols in the Defmodule
|
828
917
|
|
829
918
|
```ruby
|
830
|
-
CLIPS::Environment.
|
831
|
-
|
919
|
+
CLIPS::Environment::Defmodule.get_deftemplate_list(defmodule)
|
920
|
+
defmodule.get_deftemplate_list
|
832
921
|
```
|
833
922
|
|
834
|
-
|
835
|
-
### `CLIPS::Environment#find_deftemplate`
|
923
|
+
#### `CLIPS::Environment::Defmodule.get_defrule_list` / `CLIPS::Environment::Defmodule#get_defrule_list`
|
836
924
|
|
837
|
-
|
925
|
+
Return an array of Defrule names as symbols in the Defmodule
|
838
926
|
|
839
927
|
```ruby
|
840
|
-
CLIPS::Environment.
|
841
|
-
|
928
|
+
CLIPS::Environment::Defmodule.get_defrule_list(defmodule)
|
929
|
+
defmodule.get_defrule_list
|
842
930
|
```
|
843
931
|
|
844
|
-
###
|
845
|
-
### `CLIPS::Environment#find_defclass`
|
932
|
+
### Deftemplate Methods
|
846
933
|
|
847
|
-
|
848
|
-
|
849
|
-
```ruby
|
850
|
-
CLIPS::Environment.find_defclass(:a)
|
851
|
-
env.find_defclass("foo")
|
852
|
-
```
|
853
|
-
|
854
|
-
### `CLIPS::Environment::Deftemplate.name`
|
855
|
-
### `CLIPS::Environment::Deftemplate#name`
|
934
|
+
#### `CLIPS::Environment::Deftemplate.name` / `CLIPS::Environment::Deftemplate#name`
|
856
935
|
|
857
936
|
Returns the name of a deftemplate as a symbol
|
858
937
|
|
@@ -861,8 +940,7 @@ CLIPS::Environment::Deftemplate.name(deftemplate)
|
|
861
940
|
deftemplate.name
|
862
941
|
```
|
863
942
|
|
864
|
-
|
865
|
-
### `CLIPS::Environment::Deftemplate#pp_form`
|
943
|
+
#### `CLIPS::Environment::Deftemplate.pp_form` / `CLIPS::Environment::Deftemplate#pp_form`
|
866
944
|
|
867
945
|
Returns a pretty printed string representation of the Deftemplate
|
868
946
|
|
@@ -871,8 +949,7 @@ CLIPS::Environment::Deftemplate.pp_form(deftemplate)
|
|
871
949
|
deftemplate.pp_form
|
872
950
|
```
|
873
951
|
|
874
|
-
|
875
|
-
### `CLIPS::Environment::Deftemplate#assert_hash`
|
952
|
+
#### `CLIPS::Environment::Deftemplate.assert_hash` / `CLIPS::Environment::Deftemplate#assert_hash`
|
876
953
|
|
877
954
|
Asserts a hash in the clips environment that a Deftemplate is defined in.
|
878
955
|
Returns the Fact object that was just asserted
|
@@ -882,8 +959,7 @@ CLIPS::Environment::Deftemplate.assert_hash(deftemplate, foo: :bar)
|
|
882
959
|
deftemplate.assert_hash(foo: :bar)
|
883
960
|
```
|
884
961
|
|
885
|
-
|
886
|
-
### `CLIPS::Environment::Deftemplate#defmodule_name`
|
962
|
+
#### `CLIPS::Environment::Deftemplate.defmodule_name` / `CLIPS::Environment::Deftemplate#defmodule_name`
|
887
963
|
|
888
964
|
Returns the name of the defmodule in which the deftemplate is defined
|
889
965
|
|
@@ -892,8 +968,7 @@ CLIPS::Environment::Deftemplate.defmodule_name(deftemplate)
|
|
892
968
|
deftemplate.defmodule_name
|
893
969
|
```
|
894
970
|
|
895
|
-
|
896
|
-
### `CLIPS::Environment::Deftemplate#defmodule`
|
971
|
+
#### `CLIPS::Environment::Deftemplate.defmodule` / `CLIPS::Environment::Deftemplate#defmodule`
|
897
972
|
|
898
973
|
Returns the defmodule in which the deftemplate is defined
|
899
974
|
|
@@ -902,8 +977,7 @@ CLIPS::Environment::Deftemplate.defmodule(deftemplate)
|
|
902
977
|
deftemplate.defmodule
|
903
978
|
```
|
904
979
|
|
905
|
-
|
906
|
-
### `CLIPS::Environment::Deftemplate#slot_names`
|
980
|
+
#### `CLIPS::Environment::Deftemplate.slot_names` / `CLIPS::Environment::Deftemplate#slot_names`
|
907
981
|
|
908
982
|
Returns the slot names of a deftemplate as symbols
|
909
983
|
|
@@ -912,8 +986,7 @@ CLIPS::Environment::Deftemplate.slot_names(deftemplate)
|
|
912
986
|
deftemplate.slot_names
|
913
987
|
```
|
914
988
|
|
915
|
-
|
916
|
-
### `CLIPS::Environment::Deftemplate#is_deletable`
|
989
|
+
#### `CLIPS::Environment::Deftemplate.is_deletable` / `CLIPS::Environment::Deftemplate#is_deletable`
|
917
990
|
|
918
991
|
Returns a boolean whether the Deftemplate is deletable or not
|
919
992
|
|
@@ -922,8 +995,7 @@ CLIPS::Environment::Deftemplate.is_deletable(deftemplate)
|
|
922
995
|
deftemplate.is_deletable
|
923
996
|
```
|
924
997
|
|
925
|
-
|
926
|
-
### `CLIPS::Environment::Deftemplate#is_implied`
|
998
|
+
#### `CLIPS::Environment::Deftemplate.is_implied` / `CLIPS::Environment::Deftemplate#is_implied`
|
927
999
|
|
928
1000
|
Returns a boolean whether the Deftemplate is implied or not.
|
929
1001
|
If the fact is an ordered fact, the Deftemplate is implied.
|
@@ -934,8 +1006,7 @@ CLIPS::Environment::Deftemplate.is_implied(deftemplate)
|
|
934
1006
|
deftemplate.is_implied
|
935
1007
|
```
|
936
1008
|
|
937
|
-
|
938
|
-
### `CLIPS::Environment::Deftemplate#slot_allowed_values`
|
1009
|
+
#### `CLIPS::Environment::Deftemplate.slot_allowed_values` / `CLIPS::Environment::Deftemplate#slot_allowed_values`
|
939
1010
|
|
940
1011
|
Returns the allowed values for the slot of a deftemplate as symbols
|
941
1012
|
|
@@ -944,8 +1015,7 @@ CLIPS::Environment::Deftemplate.slot_allowed_values(deftemplate, :foo)
|
|
944
1015
|
deftemplate.slot_allowed_values('bar')
|
945
1016
|
```
|
946
1017
|
|
947
|
-
|
948
|
-
### `CLIPS::Environment::Deftemplate#slot_default_value`
|
1018
|
+
#### `CLIPS::Environment::Deftemplate.slot_default_value` / `CLIPS::Environment::Deftemplate#slot_default_value`
|
949
1019
|
|
950
1020
|
Returns the default value(s) for the slot of a deftemplate as symbols
|
951
1021
|
|
@@ -954,8 +1024,7 @@ CLIPS::Environment::Deftemplate.slot_default_value(deftemplate, :foo)
|
|
954
1024
|
deftemplate.slot_default_value('bar')
|
955
1025
|
```
|
956
1026
|
|
957
|
-
|
958
|
-
### `CLIPS::Environment::Deftemplate#slot_types`
|
1027
|
+
#### `CLIPS::Environment::Deftemplate.slot_types` / `CLIPS::Environment::Deftemplate#slot_types`
|
959
1028
|
|
960
1029
|
Returns the slot type(s) for the named slot of a deftemplate as symbols.
|
961
1030
|
Possible types are as follows:
|
@@ -979,8 +1048,7 @@ CLIPS::Environment::Deftemplate.slot_types(deftemplate, :foo)
|
|
979
1048
|
deftemplate.slot_types('bar')
|
980
1049
|
```
|
981
1050
|
|
982
|
-
|
983
|
-
### `CLIPS::Environment::Deftemplate#slot_range`
|
1051
|
+
#### `CLIPS::Environment::Deftemplate.slot_range` / `CLIPS::Environment::Deftemplate#slot_range`
|
984
1052
|
|
985
1053
|
Returns the range of a named slot of a deftemplate as integers or symbols (in case of infinity).
|
986
1054
|
|
@@ -989,8 +1057,7 @@ CLIPS::Environment::Deftemplate.slot_range(deftemplate, :foo)
|
|
989
1057
|
deftemplate.slot_range('bar')
|
990
1058
|
```
|
991
1059
|
|
992
|
-
|
993
|
-
### `CLIPS::Environment::Deftemplate#slot_cardinality`
|
1060
|
+
#### `CLIPS::Environment::Deftemplate.slot_cardinality` / `CLIPS::Environment::Deftemplate#slot_cardinality`
|
994
1061
|
|
995
1062
|
Returns the cardinality of a named slot of a deftemplate as integers or symbols (in case of infinity).
|
996
1063
|
|
@@ -999,8 +1066,7 @@ CLIPS::Environment::Deftemplate.slot_cardinality(deftemplate, :foo)
|
|
999
1066
|
deftemplate.slot_cardinality('bar')
|
1000
1067
|
```
|
1001
1068
|
|
1002
|
-
|
1003
|
-
### `CLIPS::Environment::Deftemplate#slot_existp`
|
1069
|
+
#### `CLIPS::Environment::Deftemplate.slot_existp` / `CLIPS::Environment::Deftemplate#slot_existp`
|
1004
1070
|
|
1005
1071
|
Returns a boolean for whether or not the slot with a given name
|
1006
1072
|
exists on the Deftemplate.
|
@@ -1010,8 +1076,7 @@ CLIPS::Environment::Deftemplate.slot_existp(deftemplate, :foo)
|
|
1010
1076
|
deftemplate.slot_existp('bar')
|
1011
1077
|
```
|
1012
1078
|
|
1013
|
-
|
1014
|
-
### `CLIPS::Environment::Deftemplate#slot_singlep`
|
1079
|
+
#### `CLIPS::Environment::Deftemplate.slot_singlep` / `CLIPS::Environment::Deftemplate#slot_singlep`
|
1015
1080
|
|
1016
1081
|
Returns a boolean for whether or not the slot with a given name
|
1017
1082
|
on the Deftemplate is a single slot.
|
@@ -1021,8 +1086,7 @@ CLIPS::Environment::Deftemplate.slot_singlep(deftemplate, :foo)
|
|
1021
1086
|
deftemplate.slot_singlep('bar')
|
1022
1087
|
```
|
1023
1088
|
|
1024
|
-
|
1025
|
-
### `CLIPS::Environment::Deftemplate#slot_multip`
|
1089
|
+
#### `CLIPS::Environment::Deftemplate.slot_multip` / `CLIPS::Environment::Deftemplate#slot_multip`
|
1026
1090
|
|
1027
1091
|
Returns a boolean for whether or not the slot with a given name
|
1028
1092
|
on the Deftemplate is a multislot.
|
@@ -1032,8 +1096,7 @@ CLIPS::Environment::Deftemplate.slot_multip(deftemplate, :foo)
|
|
1032
1096
|
deftemplate.slot_multip('bar')
|
1033
1097
|
```
|
1034
1098
|
|
1035
|
-
|
1036
|
-
### `CLIPS::Environment::Deftemplate#slot_defaultp`
|
1099
|
+
#### `CLIPS::Environment::Deftemplate.slot_defaultp` / `CLIPS::Environment::Deftemplate#slot_defaultp`
|
1037
1100
|
|
1038
1101
|
Returns a symbol representing the type of default value a slot has
|
1039
1102
|
on the Deftemplate. Possible return values are as follows:
|
@@ -1049,38 +1112,7 @@ CLIPS::Environment::Deftemplate.slot_defaultp(deftemplate, :foo)
|
|
1049
1112
|
deftemplate.slot_defaultp('bar')
|
1050
1113
|
```
|
1051
1114
|
|
1052
|
-
|
1053
|
-
### `CLIPS::Environment::Defmodule#get_defclass_list`
|
1054
|
-
|
1055
|
-
Return an array of Defclass names as symbols in the Defmodule
|
1056
|
-
|
1057
|
-
```ruby
|
1058
|
-
CLIPS::Environment::Defmodule.get_defclass_list(defmodule)
|
1059
|
-
defmodule.get_defclass_list
|
1060
|
-
```
|
1061
|
-
|
1062
|
-
### `CLIPS::Environment::Defmodule.get_deftemplate_list`
|
1063
|
-
### `CLIPS::Environment::Defmodule#get_deftemplate_list`
|
1064
|
-
|
1065
|
-
Return an array of Deftemplate names as symbols in the Defmodule
|
1066
|
-
|
1067
|
-
```ruby
|
1068
|
-
CLIPS::Environment::Defmodule.get_deftemplate_list(defmodule)
|
1069
|
-
defmodule.get_deftemplate_list
|
1070
|
-
```
|
1071
|
-
|
1072
|
-
### `CLIPS::Environment::Defmodule.get_defrule_list`
|
1073
|
-
### `CLIPS::Environment::Defmodule#get_defrule_list`
|
1074
|
-
|
1075
|
-
Return an array of Defrule names as symbols in the Defmodule
|
1076
|
-
|
1077
|
-
```ruby
|
1078
|
-
CLIPS::Environment::Defmodule.get_defrule_list(defmodule)
|
1079
|
-
defmodule.get_defrule_list
|
1080
|
-
```
|
1081
|
-
|
1082
|
-
### `CLIPS::Environment.find_deffacts`
|
1083
|
-
### `CLIPS::Environment#find_deffacts`
|
1115
|
+
#### `CLIPS::Environment.find_deffacts` / `CLIPS::Environment#find_deffacts`
|
1084
1116
|
|
1085
1117
|
Finds a deffacts by name and returns a CLIPS::Environment::Deffacts object
|
1086
1118
|
|
@@ -1089,8 +1121,9 @@ CLIPS::Environment.find_deffacts(:a)
|
|
1089
1121
|
env.find_deffacts("foo")
|
1090
1122
|
```
|
1091
1123
|
|
1092
|
-
###
|
1093
|
-
|
1124
|
+
### Deffacts Methods
|
1125
|
+
|
1126
|
+
#### `CLIPS::Environment::Deffacts.name` / `CLIPS::Environment::Deffacts#name`
|
1094
1127
|
|
1095
1128
|
Returns the name of a deffacts as a symbol
|
1096
1129
|
|
@@ -1099,8 +1132,7 @@ CLIPS::Environment::Deffacts.name(deffacts)
|
|
1099
1132
|
deffacts.name
|
1100
1133
|
```
|
1101
1134
|
|
1102
|
-
|
1103
|
-
### `CLIPS::Environment::Deffacts#pp_form`
|
1135
|
+
#### `CLIPS::Environment::Deffacts.pp_form` / `CLIPS::Environment::Deffacts#pp_form`
|
1104
1136
|
|
1105
1137
|
Returns a pretty printed string representation of the Deffacts
|
1106
1138
|
|
@@ -1109,54 +1141,6 @@ CLIPS::Environment::Deffacts.pp_form(deffacts)
|
|
1109
1141
|
deffacts.pp_form
|
1110
1142
|
```
|
1111
1143
|
|
1112
|
-
### `CLIPS::Environment.watch`
|
1113
|
-
### `env.watch`
|
1114
|
-
### `CLIPS::Environment.unwatch`
|
1115
|
-
### `env.unwatch`
|
1116
|
-
|
1117
|
-
"Watch" or "Unwatch" a specific thing that happens in the CLIPS environment.
|
1118
|
-
There are several things that may be watched (or unwatched) such that CLIPS will
|
1119
|
-
report debugging information to `STDOUT`. This gem provides two ways to watch
|
1120
|
-
or unwatch a debug item: either pass the watch item as a symbol to `watch` or
|
1121
|
-
`unwatch`, or use the corresponding `watch_foo` or `unwatch_foo` methods where
|
1122
|
-
`foo` is replaced by the watch item (as listed):
|
1123
|
-
|
1124
|
-
```ruby
|
1125
|
-
:all
|
1126
|
-
:facts
|
1127
|
-
:instances
|
1128
|
-
:slots
|
1129
|
-
:rules
|
1130
|
-
:activations
|
1131
|
-
:messages
|
1132
|
-
:message_handlers
|
1133
|
-
:generic_functions
|
1134
|
-
:methods
|
1135
|
-
:deffunctions
|
1136
|
-
:compilations
|
1137
|
-
:statistics
|
1138
|
-
:globals
|
1139
|
-
:focus
|
1140
|
-
```
|
1141
|
-
|
1142
|
-
```ruby
|
1143
|
-
CLIPS::Environment.watch_facts
|
1144
|
-
env.watch_statistics
|
1145
|
-
CLIPS::Environment.unwatch(:facts)
|
1146
|
-
env.unwatch(:statistics)
|
1147
|
-
```
|
1148
|
-
|
1149
|
-
### `CLIPS::Environment.get_watch_state`
|
1150
|
-
### `env.get_watch_state`
|
1151
|
-
|
1152
|
-
Returns a bool representing whether or not the given debug item
|
1153
|
-
is currently being watched in the environment.
|
1154
|
-
|
1155
|
-
```ruby
|
1156
|
-
CLIPS::Environment.get_watch_state(env, :facts)
|
1157
|
-
env.get_watch_state(:methods)
|
1158
|
-
```
|
1159
|
-
|
1160
1144
|
## Running the tests
|
1161
1145
|
|
1162
1146
|
Simply do `rake compile` and then `rake test` in order to run the tests.
|