clipsruby 0.0.25 → 0.0.26

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -0
  3. data/ext/clipsruby/clipsruby.c +99 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1856bf108cc073000e859ba1b7552a781471fef0503640a2741d555990b74ae8
4
- data.tar.gz: 667938c636e983f3ae6f90c3ba20363273f7189c5cdfc9e0d472c34c97656b01
3
+ metadata.gz: fb3538a29ed740232a6a18314da3443bf632274e06fcb893cba9c70b0797353d
4
+ data.tar.gz: 49d5cf4c8e4435fb0b35cfe2434f2aeb12f0563e859c9b0fc93fb8d64b47ee29
5
5
  SHA512:
6
- metadata.gz: d2c746946cb8d3bcf43c59587d61c95e636d04b233c8065354f1b16319ef5e195cd5004ddf56e2083a9837995ed21685c71d3bc7bad815066f50039e33af18ec
7
- data.tar.gz: 5ef09dd92b97e409b012c7183673d11871a3bba2e494467bbf84f91d31e1db29d40c67b6fd2c242d22af113f6a9c6c14ebdde771a7486bbf7299f324608ba216
6
+ metadata.gz: 1bb0d0617bcf972ca6cbad967ff271e697920e21442d978ce9ee289c0f7e81f53b30fe1b722e334649ed274b62f10e2728683f8e5df84853f3ca6575f8a11444
7
+ data.tar.gz: 66b6617635f3ba892008749dee6645cbc6652e3815b19c37bea2eb752a231d342c0d0ab1873faae8bc14e07b238c2b298f3574907ef4fae7d7dae0a0cd0a30bd
data/README.md CHANGED
@@ -621,6 +621,51 @@ CLIPS::Environment::Deftemplate.slot_default_value(deftemplate, :foo)
621
621
  deftemplate.slot_default_value('bar')
622
622
  ```
623
623
 
624
+ ### `CLIPS::Environment::Deftemplate.slot_types`
625
+ ### `CLIPS::Environment::Deftemplate#slot_types`
626
+
627
+ Returns the slot type(s) for the named slot of a deftemplate as symbols.
628
+ Possible types are as follows:
629
+
630
+ ```ruby
631
+ :SYMBOL
632
+ :STRING
633
+ :LEXEME
634
+ :INTEGER
635
+ :FLOAT
636
+ :NUMBER
637
+ :"INSTANCE-NAME"
638
+ :"INSTANCE-ADDRESS"
639
+ :INSTANCE
640
+ :"EXTERNAL-ADDRESS"
641
+ :"FACT-ADDRESS"
642
+ ```
643
+
644
+ ```ruby
645
+ CLIPS::Environment::Deftemplate.slot_types(deftemplate, :foo)
646
+ deftemplate.slot_types('bar')
647
+ ```
648
+
649
+ ### `CLIPS::Environment::Deftemplate.slot_range`
650
+ ### `CLIPS::Environment::Deftemplate#slot_range`
651
+
652
+ Returns the range of a named slot of a deftemplate as integers or symbols (in case of infinity).
653
+
654
+ ```ruby
655
+ CLIPS::Environment::Deftemplate.slot_range(deftemplate, :foo)
656
+ deftemplate.slot_range('bar')
657
+ ```
658
+
659
+ ### `CLIPS::Environment::Deftemplate.slot_cardinality`
660
+ ### `CLIPS::Environment::Deftemplate#slot_cardinality`
661
+
662
+ Returns the cardinality of a named slot of a deftemplate as integers or symbols (in case of infinity).
663
+
664
+ ```ruby
665
+ CLIPS::Environment::Deftemplate.slot_cardinality(deftemplate, :foo)
666
+ deftemplate.slot_cardinality('bar')
667
+ ```
668
+
624
669
  ### `CLIPS::Environment::Defmodule.get_deftemplate_list`
625
670
  ### `CLIPS::Environment::Defmodule#get_deftemplate_list`
626
671
 
@@ -1300,6 +1300,99 @@ static VALUE clips_environment_deftemplate_static_slot_default_value(VALUE self,
1300
1300
  }
1301
1301
 
1302
1302
 
1303
+ static VALUE clips_environment_deftemplate_slot_types(VALUE self, VALUE slot_name)
1304
+ {
1305
+ Deftemplate *template;
1306
+ CLIPSValue slot_types;
1307
+ VALUE out;
1308
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1309
+
1310
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1311
+
1312
+ switch (TYPE(slot_name)) {
1313
+ case T_STRING:
1314
+ DeftemplateSlotTypes(template, StringValueCStr(slot_name), &slot_types);
1315
+ break;
1316
+ case T_SYMBOL:
1317
+ DeftemplateSlotTypes(template, rb_id2name(SYM2ID(slot_name)), &slot_types);
1318
+ break;
1319
+ default:
1320
+ rb_warn("slot name must be string or symbol in call to slot_types!");
1321
+ return Qnil;
1322
+ }
1323
+
1324
+ CLIPSValue_to_VALUE(&slot_types, &out, &rbEnvironment);
1325
+
1326
+ return out;
1327
+ }
1328
+
1329
+ static VALUE clips_environment_deftemplate_static_slot_types(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1330
+ {
1331
+ return clips_environment_deftemplate_slot_types(rbEnvironment, slot_name);
1332
+ }
1333
+
1334
+ static VALUE clips_environment_deftemplate_slot_range(VALUE self, VALUE slot_name)
1335
+ {
1336
+ Deftemplate *template;
1337
+ CLIPSValue slot_range;
1338
+ VALUE out;
1339
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1340
+
1341
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1342
+
1343
+ switch (TYPE(slot_name)) {
1344
+ case T_STRING:
1345
+ DeftemplateSlotRange(template, StringValueCStr(slot_name), &slot_range);
1346
+ break;
1347
+ case T_SYMBOL:
1348
+ DeftemplateSlotRange(template, rb_id2name(SYM2ID(slot_name)), &slot_range);
1349
+ break;
1350
+ default:
1351
+ rb_warn("slot name must be string or symbol in call to slot_range!");
1352
+ return Qnil;
1353
+ }
1354
+
1355
+ CLIPSValue_to_VALUE(&slot_range, &out, &rbEnvironment);
1356
+
1357
+ return out;
1358
+ }
1359
+
1360
+ static VALUE clips_environment_deftemplate_static_slot_range(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1361
+ {
1362
+ return clips_environment_deftemplate_slot_range(rbEnvironment, slot_name);
1363
+ }
1364
+
1365
+ static VALUE clips_environment_deftemplate_slot_cardinality(VALUE self, VALUE slot_name)
1366
+ {
1367
+ Deftemplate *template;
1368
+ CLIPSValue slot_cardinality;
1369
+ VALUE out;
1370
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1371
+
1372
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1373
+
1374
+ switch (TYPE(slot_name)) {
1375
+ case T_STRING:
1376
+ DeftemplateSlotCardinality(template, StringValueCStr(slot_name), &slot_cardinality);
1377
+ break;
1378
+ case T_SYMBOL:
1379
+ DeftemplateSlotCardinality(template, rb_id2name(SYM2ID(slot_name)), &slot_cardinality);
1380
+ break;
1381
+ default:
1382
+ rb_warn("slot name must be string or symbol in call to slot_cardinality!");
1383
+ return Qnil;
1384
+ }
1385
+
1386
+ CLIPSValue_to_VALUE(&slot_cardinality, &out, &rbEnvironment);
1387
+
1388
+ return out;
1389
+ }
1390
+
1391
+ static VALUE clips_environment_deftemplate_static_slot_cardinality(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1392
+ {
1393
+ return clips_environment_deftemplate_slot_cardinality(rbEnvironment, slot_name);
1394
+ }
1395
+
1303
1396
  static VALUE clips_environment_fact_retract(VALUE self)
1304
1397
  {
1305
1398
  Fact *fact;
@@ -2844,6 +2937,12 @@ void Init_clipsruby(void)
2844
2937
  rb_define_method(rbDeftemplate, "slot_allowed_values", clips_environment_deftemplate_slot_allowed_values, 1);
2845
2938
  rb_define_singleton_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_static_slot_default_value, 2);
2846
2939
  rb_define_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_slot_default_value, 1);
2940
+ rb_define_singleton_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_static_slot_types, 2);
2941
+ rb_define_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_slot_types, 1);
2942
+ rb_define_singleton_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_static_slot_range, 2);
2943
+ rb_define_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_slot_range, 1);
2944
+ rb_define_singleton_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_static_slot_cardinality, 2);
2945
+ rb_define_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_slot_cardinality, 1);
2847
2946
 
2848
2947
  VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
2849
2948
  rb_define_alloc_func(rbDefmodule, defmodule_alloc);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipsruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Johnston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-16 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calling the CLIPS programming language from within Ruby
14
14
  email: mrryanjohnston@gmail.com