supplement 2.17 → 2.18

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/README +1 -1
  3. data/lib/supplement.c +30 -0
  4. data/lib/supplement.h +11 -8
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73e018e3f33dcfe0bea472488523a0afac6633396c4e8e76eab8afaef8a69402
4
- data.tar.gz: fc145b68d752ee76ceb9a2aa8c37af81039ccf29692bc574f8c6960c24c1f983
3
+ metadata.gz: 561912aa02f069434802b541add075b1da590f48683a2fab71ca49b3d383303d
4
+ data.tar.gz: d3c555d5ee6178288fbaa106056c25969e8e1b95aea3acb239c788a33bf333bd
5
5
  SHA512:
6
- metadata.gz: 7af046c1e4311bcad5705cacfcd8404bc58162571bbb76f923d1abf0e0c4269a087018bf79174a46ffd02dea5c708f75b189e292799f0eda7467d0718d8bbeb3
7
- data.tar.gz: fc90b82a5585635d96fc4cd2f079082744b4bd925c033d2a5feb37a170b59c973f5a8be663fa64d1d61f19013e0afda36f8a0559683a55a2aecf6b0a80dc27e4
6
+ metadata.gz: 62d3318a08eb07bab3c467012f13f5404237dd02444351ff982c4c387666ee1f3704b7523b3ca1b8c93e342b1d8494367929d28fc115b9c2fe4c86a198c87b2d
7
+ data.tar.gz: 4be7ab9130603ad97a223645952a2c6d388b0e483a0a8ffa89a06f64ab337f2d3d2638feefe328901d9b2330f136b098c3b35d6389e52bea0f9cf209ad7e7c6b
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.17 -- Useful Ruby enhancements
1
+ = supplement 2.18 -- Useful Ruby enhancements
2
2
 
3
3
 
4
4
  Some simple Ruby extensions.
data/lib/supplement.c CHANGED
@@ -1511,6 +1511,32 @@ bsruby_set_thread_critical( VALUE c)
1511
1511
  */
1512
1512
 
1513
1513
 
1514
+
1515
+ /*
1516
+ * Document-class: Object
1517
+ */
1518
+
1519
+ /*
1520
+ * call-seq:
1521
+ * to_bool -> true
1522
+ *
1523
+ * Returns true for anything but +nil+ and +false+.
1524
+ */
1525
+
1526
+ VALUE
1527
+ rb_nil_to_bool( VALUE obj)
1528
+ {
1529
+ return Qfalse;
1530
+ }
1531
+
1532
+ VALUE
1533
+ rb_obj_to_bool( VALUE obj)
1534
+ {
1535
+ return Qtrue;
1536
+ }
1537
+
1538
+
1539
+
1514
1540
  void Init_supplement( void)
1515
1541
  {
1516
1542
  rb_define_method( rb_cObject, "new_string", rb_obj_new_string, 0);
@@ -1594,6 +1620,10 @@ void Init_supplement( void)
1594
1620
  rb_define_method( rb_cStruct, "fields", rb_struct_fields, -1);
1595
1621
  rb_define_alias( rb_cStruct, "fetch_values", "fields");
1596
1622
 
1623
+ rb_define_method( rb_cNilClass, "to_bool", rb_nil_to_bool, 0);
1624
+ rb_define_method( rb_cFalseClass, "to_bool", rb_nil_to_bool, 0);
1625
+ rb_define_method( rb_cObject, "to_bool", rb_obj_to_bool, 0);
1626
+
1597
1627
  id_delete_at = rb_intern( "delete_at");
1598
1628
  id_cmp = rb_intern( "<=>");
1599
1629
  id_eqq = 0;
data/lib/supplement.h CHANGED
@@ -45,6 +45,12 @@ extern VALUE rb_str_ord( VALUE);
45
45
  #endif
46
46
  extern VALUE rb_str_axe( int, VALUE *, VALUE);
47
47
 
48
+ extern VALUE rb_num_pos_p( VALUE);
49
+ extern VALUE rb_num_neg_p( VALUE);
50
+ extern VALUE rb_num_grammatical( VALUE, VALUE, VALUE);
51
+ extern VALUE rb_num_sqrt( VALUE);
52
+ extern VALUE rb_num_cbrt( VALUE);
53
+
48
54
  extern VALUE rb_ary_notempty_p( VALUE);
49
55
  extern VALUE rb_ary_indexes( VALUE);
50
56
  extern VALUE rb_ary_range( VALUE);
@@ -58,12 +64,6 @@ extern VALUE rb_ary_rindex( int, VALUE *, VALUE);
58
64
  extern VALUE rb_ary_select_bang( VALUE);
59
65
  #endif
60
66
 
61
- extern VALUE rb_num_pos_p( VALUE);
62
- extern VALUE rb_num_neg_p( VALUE);
63
- extern VALUE rb_num_grammatical( VALUE, VALUE, VALUE);
64
- extern VALUE rb_num_sqrt( VALUE);
65
- extern VALUE rb_num_cbrt( VALUE);
66
-
67
67
  extern VALUE rb_hash_notempty_p( VALUE);
68
68
 
69
69
  #ifdef FEATURE_FILE_SIZE
@@ -77,12 +77,15 @@ extern VALUE rb_dir_children( VALUE);
77
77
  extern VALUE rb_match_begin( int, VALUE *, VALUE);
78
78
  extern VALUE rb_match_end( int, VALUE *, VALUE);
79
79
 
80
- extern VALUE rb_struct_fields( int, VALUE *, VALUE);
81
-
82
80
  #ifdef FEATURE_THREAD_EXCLUSIVE
83
81
  extern VALUE rb_thread_exclusive( void);
84
82
  #endif
85
83
 
84
+ extern VALUE rb_struct_fields( int, VALUE *, VALUE);
85
+
86
+ extern VALUE rb_nil_to_bool( VALUE);
87
+ extern VALUE rb_obj_to_bool( VALUE);
88
+
86
89
  extern void Init_supplement( void);
87
90
 
88
91
  #endif
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.17'
4
+ version: '2.18'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-12 00:00:00.000000000 Z
11
+ date: 2023-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake