clipsruby 0.0.27 → 0.0.29

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 +22 -0
  3. data/ext/clipsruby/clipsruby.c +44 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78727d42b56ea442a2ff5b487d3cc209bcfda2068724a7507021fa44845dee9c
4
- data.tar.gz: f22f44dc57cdf4d8e1491b1b9790c45a15264b9fcad34b3b768e6deb9655a475
3
+ metadata.gz: 305eb61d4442d705a0e3cf576056151266170cd5a3c8e67d2c2d01efe65ed540
4
+ data.tar.gz: 2de8f8f91cfc7c529239f1fbbd8f7701bfc08ff24e7576a162ab4d4bd3111f18
5
5
  SHA512:
6
- metadata.gz: abd28dcfe9303c838636a209fdcd1d043ae7c0fa72b84ae49ea52c2e79aed9f2d65c58cd02746cdfd9bc4230476dcb4289ea32cc36f2e335ba54371008146e3b
7
- data.tar.gz: a9dd833a9d045713eb20ab356d65bb80c7a61d528518f5b7dd83482a059042a3499f3fb33f06259ab667af3fc2dea22102bcb103acf50f41900537301980d5d0
6
+ metadata.gz: 271deb181e3aea58a76b104ac876e6130be561e56261175bcb9ef0ddb334a7ebbeda13a3e2d964c0291fe4b47d2f3f806c83d09dae90efe50bd57aca718bc41e
7
+ data.tar.gz: 64a925ca77540df3b8b77ce15004369f478431909fcb6a7ffc4fd4f9f516e67362ddd5b4a0012832cf3e64ba54051fca16b870a37784ce01cf3cdcf66e4a4653
data/README.md CHANGED
@@ -312,6 +312,16 @@ CLIPS::Environment::Fact.pp_form(fact)
312
312
  fact.pp_form
313
313
  ```
314
314
 
315
+ ### `CLIPS::Environment::Fact.existp`
316
+ ### `CLIPS::Environment::Fact#existp`
317
+
318
+ Returns a boolean representing whether or not a Fact has been retracted
319
+
320
+ ```ruby
321
+ CLIPS::Environment::Fact.existp(fact)
322
+ fact.existp
323
+ ```
324
+
315
325
  ### `CLIPS::Environment::Fact.to_h`
316
326
  ### `CLIPS::Environment::Fact#to_h`
317
327
 
@@ -601,6 +611,18 @@ CLIPS::Environment::Deftemplate.is_deletable(deftemplate)
601
611
  deftemplate.is_deletable
602
612
  ```
603
613
 
614
+ ### `CLIPS::Environment::Deftemplate.is_implied`
615
+ ### `CLIPS::Environment::Deftemplate#is_implied`
616
+
617
+ Returns a boolean whether the Deftemplate is implied or not.
618
+ If the fact is an ordered fact, the Deftemplate is implied.
619
+ Otherwise, the Deftemplate is considered explicitly defined.
620
+
621
+ ```ruby
622
+ CLIPS::Environment::Deftemplate.is_implied(deftemplate)
623
+ deftemplate.is_implied
624
+ ```
625
+
604
626
  ### `CLIPS::Environment::Deftemplate.slot_allowed_values`
605
627
  ### `CLIPS::Environment::Deftemplate#slot_allowed_values`
606
628
 
@@ -188,6 +188,10 @@ static VALUE clips_environment_assert_string(VALUE self, VALUE string)
188
188
 
189
189
  Fact *fact = AssertString(env, StringValueCStr(string));
190
190
 
191
+ if (fact == NULL) {
192
+ return Qnil;
193
+ }
194
+
191
195
  VALUE rb_fact =
192
196
  TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Fact")), &Fact_type, fact);
193
197
 
@@ -1796,6 +1800,24 @@ static VALUE clips_environment_fact_static_pp_form(int argc, VALUE *argv, VALUE
1796
1800
  return toReturn;
1797
1801
  }
1798
1802
 
1803
+ static VALUE clips_environment_fact_existp(VALUE self)
1804
+ {
1805
+ Fact *fact;
1806
+
1807
+ TypedData_Get_Struct(self, Fact, &Fact_type, fact);
1808
+
1809
+ if (FactExistp(fact)) {
1810
+ return Qtrue;
1811
+ } else {
1812
+ return Qfalse;
1813
+ }
1814
+ }
1815
+
1816
+ static VALUE clips_environment_fact_static_existp(VALUE self, VALUE rbFact)
1817
+ {
1818
+ return clips_environment_fact_existp(rbFact);
1819
+ }
1820
+
1799
1821
  static VALUE clips_environment_get_fact_list(int argc, VALUE *argv, VALUE rbEnvironment) {
1800
1822
  VALUE defmodule_or_defmodule_name;
1801
1823
  Environment *env;
@@ -2092,6 +2114,24 @@ static VALUE clips_environment_deftemplate_static_is_deletable(VALUE self, VALUE
2092
2114
  return clips_environment_deftemplate_is_deletable(rbDeftemplate);
2093
2115
  }
2094
2116
 
2117
+ static VALUE clips_environment_deftemplate_is_implied(VALUE self)
2118
+ {
2119
+ Deftemplate *deftemplate;
2120
+
2121
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
2122
+
2123
+ if (deftemplate->implied) {
2124
+ return Qtrue;
2125
+ } else {
2126
+ return Qfalse;
2127
+ }
2128
+ }
2129
+
2130
+ static VALUE clips_environment_deftemplate_static_is_implied(VALUE self, VALUE rbDeftemplate)
2131
+ {
2132
+ return clips_environment_deftemplate_is_implied(rbDeftemplate);
2133
+ }
2134
+
2095
2135
  static VALUE clips_environment_deftemplate_slot_existp(VALUE self, VALUE slot_name)
2096
2136
  {
2097
2137
  Deftemplate *deftemplate;
@@ -3081,6 +3121,8 @@ void Init_clipsruby(void)
3081
3121
  rb_define_method(rbDeftemplate, "slot_multip", clips_environment_deftemplate_slot_multip, 1);
3082
3122
  rb_define_singleton_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_static_slot_defaultp, 2);
3083
3123
  rb_define_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_slot_defaultp, 1);
3124
+ rb_define_singleton_method(rbDeftemplate, "is_implied", clips_environment_deftemplate_static_is_implied, 1);
3125
+ rb_define_method(rbDeftemplate, "is_implied", clips_environment_deftemplate_is_implied, 0);
3084
3126
 
3085
3127
  VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
3086
3128
  rb_define_alloc_func(rbDefmodule, defmodule_alloc);
@@ -3115,6 +3157,8 @@ void Init_clipsruby(void)
3115
3157
  rb_define_method(rbFact, "index", clips_environment_fact_index, 0);
3116
3158
  rb_define_singleton_method(rbFact, "pp_form", clips_environment_fact_static_pp_form, -1);
3117
3159
  rb_define_method(rbFact, "pp_form", clips_environment_fact_pp_form, -1);
3160
+ rb_define_singleton_method(rbFact, "existp", clips_environment_fact_static_existp, 1);
3161
+ rb_define_method(rbFact, "existp", clips_environment_fact_existp, 0);
3118
3162
 
3119
3163
  VALUE rbDefrule = rb_define_class_under(rbEnvironment, "Defrule", rb_cObject);
3120
3164
  rb_define_alloc_func(rbDefrule, defrule_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.27
4
+ version: 0.0.29
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-18 00:00:00.000000000 Z
11
+ date: 2024-09-23 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
@@ -385,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
385
  - !ruby/object:Gem::Version
386
386
  version: '0'
387
387
  requirements: []
388
- rubygems_version: 3.5.11
388
+ rubygems_version: 3.5.16
389
389
  signing_key:
390
390
  specification_version: 4
391
391
  summary: Calling CLIPS from within Ruby