xqsr3 0.38.2 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -6
  3. data/examples/count_word_frequencies.md +12 -12
  4. data/examples/count_word_frequencies.rb +4 -4
  5. data/lib/xqsr3/array_utilities/join_with_or.rb +47 -47
  6. data/lib/xqsr3/array_utilities.rb +2 -2
  7. data/lib/xqsr3/command_line_utilities/map_option_string.rb +60 -60
  8. data/lib/xqsr3/command_line_utilities.rb +2 -2
  9. data/lib/xqsr3/containers/frequency_map.rb +399 -399
  10. data/lib/xqsr3/containers/multi_map.rb +448 -448
  11. data/lib/xqsr3/containers.rb +3 -3
  12. data/lib/xqsr3/conversion/bool_parser.rb +51 -51
  13. data/lib/xqsr3/conversion/integer_parser.rb +87 -87
  14. data/lib/xqsr3/conversion.rb +3 -3
  15. data/lib/xqsr3/diagnostics/exception_utilities.rb +145 -145
  16. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +90 -90
  17. data/lib/xqsr3/diagnostics/inspect_builder.rb +80 -80
  18. data/lib/xqsr3/diagnostics.rb +3 -3
  19. data/lib/xqsr3/doc_.rb +130 -130
  20. data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
  21. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +12 -12
  22. data/lib/xqsr3/extensions/enumerable/detect_map.rb +35 -35
  23. data/lib/xqsr3/extensions/enumerable/unique.rb +29 -28
  24. data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
  25. data/lib/xqsr3/extensions/hash/except.rb +16 -16
  26. data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
  27. data/lib/xqsr3/extensions/hash/match.rb +10 -10
  28. data/lib/xqsr3/extensions/hash/slice.rb +11 -11
  29. data/lib/xqsr3/extensions/hash.rb +1 -1
  30. data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
  31. data/lib/xqsr3/extensions/integer.rb +3 -0
  32. data/lib/xqsr3/extensions/io/writelines.rb +28 -28
  33. data/lib/xqsr3/extensions/kernel/integer.rb +20 -20
  34. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +8 -8
  35. data/lib/xqsr3/extensions/kernel.rb +1 -0
  36. data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
  37. data/lib/xqsr3/extensions/string/map_option_string.rb +4 -4
  38. data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
  39. data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
  40. data/lib/xqsr3/extensions/string/quote_if.rb +1 -1
  41. data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
  42. data/lib/xqsr3/extensions/string/to_bool.rb +8 -8
  43. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
  44. data/lib/xqsr3/extensions/string/truncate.rb +1 -1
  45. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
  46. data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -6
  47. data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -6
  48. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
  49. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -61
  50. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -7
  51. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -7
  52. data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -6
  53. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -36
  54. data/lib/xqsr3/extensions.rb +5 -5
  55. data/lib/xqsr3/hash_utilities/deep_transform.rb +65 -65
  56. data/lib/xqsr3/hash_utilities/key_matching.rb +77 -77
  57. data/lib/xqsr3/hash_utilities.rb +3 -3
  58. data/lib/xqsr3/internal_/test_unit_version_.rb +85 -85
  59. data/lib/xqsr3/io/writelines.rb +119 -119
  60. data/lib/xqsr3/quality/parameter_checking.rb +445 -445
  61. data/lib/xqsr3/quality.rb +2 -2
  62. data/lib/xqsr3/string_utilities/ends_with.rb +59 -59
  63. data/lib/xqsr3/string_utilities/nil_if_empty.rb +28 -28
  64. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +29 -29
  65. data/lib/xqsr3/string_utilities/quote_if.rb +50 -50
  66. data/lib/xqsr3/string_utilities/starts_with.rb +59 -59
  67. data/lib/xqsr3/string_utilities/to_symbol.rb +75 -75
  68. data/lib/xqsr3/string_utilities/truncate.rb +55 -55
  69. data/lib/xqsr3/string_utilities.rb +8 -8
  70. data/lib/xqsr3/version.rb +12 -12
  71. data/test/performance/frequency_map.rb +12 -12
  72. data/test/scratch/test_assert_raise_with_message.rb +11 -11
  73. data/test/unit/array_utilities/tc_join_with_or.rb +140 -140
  74. data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
  75. data/test/unit/containers/tc_frequency_map.rb +591 -591
  76. data/test/unit/containers/tc_multi_map.rb +558 -558
  77. data/test/unit/conversion/tc_integer_parser.rb +72 -72
  78. data/test/unit/conversion/tc_to_bool.rb +25 -25
  79. data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
  80. data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
  81. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
  82. data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
  83. data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
  84. data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
  85. data/test/unit/extensions/hash/tc_except.rb +28 -28
  86. data/test/unit/extensions/hash/tc_slice.rb +13 -13
  87. data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
  88. data/test/unit/extensions/integer/ts_all.rb +12 -0
  89. data/test/unit/extensions/io/tc_writelines.rb +77 -77
  90. data/test/unit/extensions/kernel/tc_integer.rb +75 -75
  91. data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
  92. data/test/unit/extensions/object/tc_inspect.rb +50 -50
  93. data/test/unit/extensions/string/tc_bool.tb +24 -24
  94. data/test/unit/extensions/string/tc_ends_with.rb +53 -53
  95. data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
  96. data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
  97. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
  98. data/test/unit/extensions/string/tc_quote_if.rb +18 -18
  99. data/test/unit/extensions/string/tc_starts_with.rb +53 -53
  100. data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
  101. data/test/unit/extensions/string/tc_truncate.rb +18 -18
  102. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
  103. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
  104. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
  105. data/test/unit/hash_utilities/tc_has_match.rb +70 -70
  106. data/test/unit/hash_utilities/tc_match.rb +83 -83
  107. data/test/unit/io/tc_writelines.rb +106 -106
  108. data/test/unit/quality/tc_parameter_checking.rb +389 -389
  109. data/test/unit/string_utilities/tc_truncate.rb +27 -27
  110. data/test/unit/tc_version.rb +15 -15
  111. metadata +6 -2
@@ -5,13 +5,13 @@
5
5
  # Purpose: ::Enumerable#detect_map extension
6
6
  #
7
7
  # Created: 3rd December 2017
8
- # Updated: 11th December 2023
8
+ # Updated: 29th March 2024
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -50,46 +50,46 @@
50
50
 
51
51
  module Enumerable
52
52
 
53
- # The +Enumerable+#+detect+ method provides a way to detect the presence
54
- # of a particular value in a collection. The only constraint is that you
55
- # get back the object unchanged.
56
- #
57
- # The +Enumerable+#+map+ method provides a way to transform the contents of
58
- # a collection. The only constraint is that you get back another
59
- # collection.
60
- #
61
- # This extension method, +Enumerable+#+detect_map+ combines the features
62
- # of both, in that it detects the presence of a particular value in a
63
- # collection and transform the detected value.
64
- #
65
- # [ 1, 2, 3 ].detect_map { |v| -2 * v if v > 2 } # => -6
66
- #
67
- # { :ab => 'cd', :ef => 'gh' }.detect_map { |k, v| v.upcase if k == :ef } # => 'GH'
68
- #
69
- # *Note:* The block is required (for technical reasons), and must have
70
- # arity 1 for sequences or 2 for associations
71
- def detect_map &block
53
+ # The +Enumerable+#+detect+ method provides a way to detect the presence
54
+ # of a particular value in a collection. The only constraint is that you
55
+ # get back the object unchanged.
56
+ #
57
+ # The +Enumerable+#+map+ method provides a way to transform the contents of
58
+ # a collection. The only constraint is that you get back another
59
+ # collection.
60
+ #
61
+ # This extension method, +Enumerable+#+detect_map+ combines the features
62
+ # of both, in that it detects the presence of a particular value in a
63
+ # collection and transform the detected value.
64
+ #
65
+ # [ 1, 2, 3 ].detect_map { |v| -2 * v if v > 2 } # => -6
66
+ #
67
+ # { :ab => 'cd', :ef => 'gh' }.detect_map { |k, v| v.upcase if k == :ef } # => 'GH'
68
+ #
69
+ # *Note:* The block is required (for technical reasons), and must have
70
+ # arity 1 for sequences or 2 for associations
71
+ def detect_map &block
72
72
 
73
- case block.arity
74
- when 1
73
+ case block.arity
74
+ when 1
75
75
 
76
- self.each do |v|
76
+ self.each do |v|
77
77
 
78
- r = yield(v) and return r
79
- end
80
- when 2
78
+ r = yield(v) and return r
79
+ end
80
+ when 2
81
81
 
82
- self.each do |k, v|
82
+ self.each do |k, v|
83
83
 
84
- r = yield(k, v) and return r
85
- end
86
- else
84
+ r = yield(k, v) and return r
85
+ end
86
+ else
87
87
 
88
- raise ArgumentError, "detect_map requires block with arity of 1 (for sequences) or 2 (for associations); block with arity #{block.arity} given to instance of #{self.class}"
89
- end
88
+ raise ArgumentError, "detect_map requires block with arity of 1 (for sequences) or 2 (for associations); block with arity #{block.arity} given to instance of #{self.class}"
89
+ end
90
90
 
91
- nil
92
- end
91
+ nil
92
+ end
93
93
  end # module Enumerable
94
94
 
95
95
  # ############################## end of file ############################# #
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/extensions/enumerable/unique.rb
3
+ # File: lib/xqsr3/extensions/enumerable/unique.rb
4
4
  #
5
- # Purpose: Adds a unique() method to the Enumerable module
5
+ # Purpose: Adds a unique() method to the Enumerable module
6
6
  #
7
- # Created: 5th March 2007
8
- # Updated: 12th April 2019
7
+ # Created: 5th March 2007
8
+ # Updated: 29th March 2024
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2007-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -52,40 +53,40 @@
52
53
 
53
54
  module Enumerable
54
55
 
55
- # Removes all duplicate elements in a sequence subject to an optional
56
- # two-parameter block in order to return an array containing unique
57
- # elements
58
- #
59
- # [ 1, 2, 3 ].unique # => [ 1, 2, 3 ]
60
- # [ 1, 2, 1, 3 ].unique # => [ 1, 2, 3 ]
61
- def unique(&block)
56
+ # Removes all duplicate elements in a sequence subject to an optional
57
+ # two-parameter block in order to return an array containing unique
58
+ # elements
59
+ #
60
+ # [ 1, 2, 3 ].unique # => [ 1, 2, 3 ]
61
+ # [ 1, 2, 1, 3 ].unique # => [ 1, 2, 3 ]
62
+ def unique(&block)
62
63
 
63
- if not block
64
+ if not block
64
65
 
65
- return unique { |a, b| a == b }
66
- else
66
+ return unique { |a, b| a == b }
67
+ else
67
68
 
68
- raise ArgumentError, "block requires two parameters" unless block.arity == 2
69
+ raise ArgumentError, "block requires two parameters" unless block.arity == 2
69
70
 
70
- ar = self.to_a
71
+ ar = self.to_a
71
72
 
72
- return ar if ar.length < 2
73
+ return ar if ar.length < 2
73
74
 
74
- r = []
75
- h = {}
75
+ r = []
76
+ h = {}
76
77
 
77
- ar.each do |v|
78
+ ar.each do |v|
78
79
 
79
- unless h.has_key?(v)
80
+ unless h.has_key?(v)
80
81
 
81
- r << v
82
- h[v] = nil
83
- end
84
- end
82
+ r << v
83
+ h[v] = nil
84
+ end
85
+ end
85
86
 
86
- return r
87
- end
88
- end
87
+ return r
88
+ end
89
+ end
89
90
  end # module Enumerable
90
91
 
91
92
  # ############################## end of file ############################# #
@@ -3,6 +3,6 @@ require 'xqsr3/hash_utilities/deep_transform'
3
3
 
4
4
  class Hash
5
5
 
6
- include ::Xqsr3::HashUtilities::DeepTransform
6
+ include ::Xqsr3::HashUtilities::DeepTransform
7
7
  end # class Hash
8
8
 
@@ -1,32 +1,32 @@
1
1
 
2
2
  unless Hash.instance_methods.include? :except!
3
3
 
4
- class Hash
4
+ class Hash
5
5
 
6
- # Removes from the instance any key-value pairs matching the
7
- # keys specified in +keys_to_delete+
8
- def except!(*keys_to_delete)
6
+ # Removes from the instance any key-value pairs matching the
7
+ # keys specified in +keys_to_delete+
8
+ def except!(*keys_to_delete)
9
9
 
10
- keys_to_delete.each do |key|
10
+ keys_to_delete.each do |key|
11
11
 
12
- self.delete key
13
- end
12
+ self.delete key
13
+ end
14
14
 
15
- self
16
- end
15
+ self
16
+ end
17
17
  end
18
18
  end
19
19
 
20
20
  unless Hash.instance_methods.include? :except
21
21
 
22
- class Hash
22
+ class Hash
23
23
 
24
- # Obtains a copy of the instance wherein any key-value pairs
25
- # matching the keys specified in +keys_to_delete+ are removed
26
- def except(*keys_to_delete)
24
+ # Obtains a copy of the instance wherein any key-value pairs
25
+ # matching the keys specified in +keys_to_delete+ are removed
26
+ def except(*keys_to_delete)
27
27
 
28
- self.dup.except!(*keys_to_delete)
29
- end
30
- end
28
+ self.dup.except!(*keys_to_delete)
29
+ end
30
+ end
31
31
  end
32
32
 
@@ -3,16 +3,16 @@ require 'xqsr3/hash_utilities/key_matching'
3
3
 
4
4
  class Hash
5
5
 
6
- # Extended method implemented by Xqsr3::HashUtilities::KeyMatching
7
- #
8
- # === Signature
9
- #
10
- # * *Parameters:*
11
- # - +re+ (Regexp) The regular expression
12
- # - +options+ (Hash) See Xqsr3::HashUtilities::KeyMatching
13
- def has_match? re, **options
6
+ # Extended method implemented by Xqsr3::HashUtilities::KeyMatching
7
+ #
8
+ # === Signature
9
+ #
10
+ # * *Parameters:*
11
+ # - +re+ (Regexp) The regular expression
12
+ # - +options+ (Hash) See Xqsr3::HashUtilities::KeyMatching
13
+ def has_match? re, **options
14
14
 
15
- return ::Xqsr3::HashUtilities::KeyMatching.has_match? self, re, **options
16
- end
15
+ return ::Xqsr3::HashUtilities::KeyMatching.has_match? self, re, **options
16
+ end
17
17
  end
18
18
 
@@ -3,16 +3,16 @@ require 'xqsr3/hash_utilities/key_matching'
3
3
 
4
4
  class Hash
5
5
 
6
- # Extended method implemented by Xqsr3::HashUtilities::KeyMatching
7
- #
8
- # === Signature
9
- #
10
- # * *Parameters:*
11
- # - +re+ (Regexp) The regular expression
12
- # - +options+ (Hash) See Xqsr3::HashUtilities::KeyMatching
13
- def match re, **options
6
+ # Extended method implemented by Xqsr3::HashUtilities::KeyMatching
7
+ #
8
+ # === Signature
9
+ #
10
+ # * *Parameters:*
11
+ # - +re+ (Regexp) The regular expression
12
+ # - +options+ (Hash) See Xqsr3::HashUtilities::KeyMatching
13
+ def match re, **options
14
14
 
15
- return ::Xqsr3::HashUtilities::KeyMatching.match self, re, **options
16
- end
15
+ return ::Xqsr3::HashUtilities::KeyMatching.match self, re, **options
16
+ end
17
17
  end
18
18
 
@@ -1,22 +1,22 @@
1
1
 
2
2
  unless Hash.instance_methods.include? :slice
3
3
 
4
- class Hash
4
+ class Hash
5
5
 
6
- def slice(*args)
6
+ def slice(*args)
7
7
 
8
- r = {}
8
+ r = {}
9
9
 
10
- args.each do |arg|
10
+ args.each do |arg|
11
11
 
12
- if self.has_key? arg
12
+ if self.has_key? arg
13
13
 
14
- r[arg] = self[arg]
15
- end
16
- end
14
+ r[arg] = self[arg]
15
+ end
16
+ end
17
17
 
18
- r
19
- end
20
- end
18
+ r
19
+ end
20
+ end
21
21
  end
22
22
 
@@ -6,6 +6,6 @@ require 'xqsr3/extensions/hash/match'
6
6
 
7
7
  unless (RUBY_VERSION.split('.').map { |v| v.to_i } <=> [ 2, 5, 0 ]) > 0
8
8
 
9
- require 'xqsr3/extensions/hash/slice'
9
+ require 'xqsr3/extensions/hash/slice'
10
10
  end
11
11
 
@@ -0,0 +1,118 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/integer/to_s_grp.rb
4
+ #
5
+ # Purpose: Adds a to_s_grp() method to the Integer class
6
+ #
7
+ # Created: 29th March 2024
8
+ # Updated: 29th March 2024
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2024, Matthew Wilson and Synesis Information Systems
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright
22
+ # notice, this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ # ##########################################################
48
+ # ::Integer
49
+
50
+ =begin
51
+ =end
52
+
53
+ class Integer
54
+
55
+ # Extends +Integer+ type with the +#to_s_grp()+ method
56
+ def to_s_grp *args, **options
57
+
58
+ separator = options[:separator] || ','
59
+
60
+ numbers =
61
+ case args.size
62
+ when 0
63
+
64
+ []
65
+ when 1
66
+ case args[0]
67
+ when ::Array
68
+
69
+ args[0]
70
+ when ::Integer
71
+
72
+ [ args[0] ]
73
+ else
74
+
75
+ raise TypeError, "parameter 'args[0]' (#{args[0].class}) must be an instance of Integer, or an array containing instance(s) of Integer"
76
+ end
77
+ else
78
+
79
+ args
80
+ end
81
+
82
+
83
+ case numbers.size
84
+ when 0
85
+
86
+ return self.to_s
87
+ when 1
88
+
89
+ return self.to_s.chars.to_a.reverse.each_slice(numbers[0]).map(&:join).join(',').reverse
90
+ else
91
+
92
+ reversed_chars = self.to_s.chars.to_a#.reverse
93
+
94
+ r = []
95
+
96
+ last_n = nil
97
+
98
+ numbers.each do |n|
99
+
100
+ r << separator unless r.empty?
101
+ r << reversed_chars.pop(n).reverse
102
+
103
+ last_n = n
104
+ end
105
+
106
+ until reversed_chars.empty?
107
+
108
+ r << separator unless r.empty?
109
+ r << reversed_chars.pop(last_n).reverse
110
+ end
111
+
112
+ r.flatten.join('').reverse
113
+ end
114
+ end
115
+ end # module Kernel
116
+
117
+ # ############################## end of file ############################# #
118
+
@@ -0,0 +1,3 @@
1
+
2
+ require 'xqsr3/extensions/integer/to_s_grp'
3
+
@@ -5,13 +5,13 @@
5
5
  # Purpose: Adds a writelines() method to the IO class
6
6
  #
7
7
  # Created: 13th April 2007
8
- # Updated: 11th December 2023
8
+ # Updated: 29th March 2024
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2007-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -55,43 +55,43 @@ require 'xqsr3/io/writelines'
55
55
 
56
56
  class IO
57
57
 
58
- # Extends +IO+ class with the +::Xqsr3::IO::write_lines+ method
59
- #
60
- #
61
- #def self.writelines(path, contents, lineSep = nil, columnSep = nil)
62
- def self.writelines(path, contents, *args)
58
+ # Extends +IO+ class with the +::Xqsr3::IO::write_lines+ method
59
+ #
60
+ #
61
+ #def self.writelines(path, contents, lineSep = nil, columnSep = nil)
62
+ def self.writelines(path, contents, *args)
63
63
 
64
- options = {}
64
+ options = {}
65
65
 
66
- case args.size
67
- when 0
66
+ case args.size
67
+ when 0
68
68
 
69
- ;
70
- when 1
69
+ ;
70
+ when 1
71
71
 
72
- arg3 = args[0]
72
+ arg3 = args[0]
73
73
 
74
- if arg3.respond_to?(:to_hash)
74
+ if arg3.respond_to?(:to_hash)
75
75
 
76
- options.merge! arg3.to_hash
77
- else
76
+ options.merge! arg3.to_hash
77
+ else
78
78
 
79
- options[:line_separator] = arg3
80
- end
81
- when 2
79
+ options[:line_separator] = arg3
80
+ end
81
+ when 2
82
82
 
83
- arg3 = args[0]
84
- arg4 = args[1]
83
+ arg3 = args[0]
84
+ arg4 = args[1]
85
85
 
86
- options[:line_separator] = arg2
87
- options[:column_separator] = arg2
88
- else
86
+ options[:line_separator] = arg2
87
+ options[:column_separator] = arg2
88
+ else
89
89
 
90
- raise ArgumentError, "wrong number of arguments (given #{2 + args.size}, expected 2..4)"
91
- end
90
+ raise ArgumentError, "wrong number of arguments (given #{2 + args.size}, expected 2..4)"
91
+ end
92
92
 
93
- ::Xqsr3::IO.writelines path, contents, **options
94
- end
93
+ ::Xqsr3::IO.writelines path, contents, **options
94
+ end
95
95
  end # class IO
96
96
 
97
97
  # ############################## end of file ############################# #
@@ -5,13 +5,13 @@
5
5
  # Purpose: Adds a Integer 'overload' to the Kernel module
6
6
  #
7
7
  # Created: 21st November 2017
8
- # Updated: 11th December 2023
8
+ # Updated: 29th March 2024
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -55,27 +55,27 @@ require 'xqsr3/conversion/integer_parser'
55
55
 
56
56
  module Kernel
57
57
 
58
- alias xqsr3_Integer_original_method Integer
58
+ alias xqsr3_Integer_original_method Integer
59
59
 
60
- # A monkey-patch extension of +Kernel#Integer+ with +options+
61
- #
62
- # === Signature
63
- #
64
- # * *Parameters:*
65
- # - +arg+ The argument to be converted (to +Fixnum+ or +Bignum+)
66
- # - +base+ A value of 0, or between 2 and 36. Defaults to 0
67
- # - +options+ An options hash, containing any of the following options
68
- # - +block+ An optional caller-supplied block that will be invoked with the +ArgumentError+ exception, allowing the caller to take additional action. If the block returns then its return value will be returned to the caller
69
- #
70
- # * *Options:*
71
- # - +:default+ A default value to be used when +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+
72
- # - +:nil+ Returns +nil+ if +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+. Ignored if +:default+ is specified
73
- def Integer(arg, base = 0, **options, &block)
60
+ # A monkey-patch extension of +Kernel#Integer+ with +options+
61
+ #
62
+ # === Signature
63
+ #
64
+ # * *Parameters:*
65
+ # - +arg+ The argument to be converted (to +Fixnum+ or +Bignum+)
66
+ # - +base+ A value of 0, or between 2 and 36. Defaults to 0
67
+ # - +options+ An options hash, containing any of the following options
68
+ # - +block+ An optional caller-supplied block that will be invoked with the +ArgumentError+ exception, allowing the caller to take additional action. If the block returns then its return value will be returned to the caller
69
+ #
70
+ # * *Options:*
71
+ # - +:default+ A default value to be used when +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+
72
+ # - +:nil+ Returns +nil+ if +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+. Ignored if +:default+ is specified
73
+ def Integer(arg, base = 0, **options, &block)
74
74
 
75
- ::Xqsr3::Conversion::IntegerParser.to_integer arg, base = 0, **options, &block
76
- end
75
+ ::Xqsr3::Conversion::IntegerParser.to_integer arg, base = 0, **options, &block
76
+ end
77
77
 
78
- private :xqsr3_Integer_original_method
78
+ private :xqsr3_Integer_original_method
79
79
  end # module Kernel
80
80
 
81
81
  # ############################## end of file ############################# #
@@ -5,13 +5,13 @@
5
5
  # Purpose: Adds a raise_with_options() method to the Kernel module
6
6
  #
7
7
  # Created: 12th February 2015
8
- # Updated: 11th December 2023
8
+ # Updated: 29th March 2024
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -55,14 +55,14 @@ require 'xqsr3/diagnostics/exception_utilities'
55
55
 
56
56
  module Kernel
57
57
 
58
- # Extends +Kernel+ module with the ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options
59
- # method
60
- def raise_with_options *args, **options
58
+ # Extends +Kernel+ module with the ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options
59
+ # method
60
+ def raise_with_options *args, **options
61
61
 
62
- options ||= {}
62
+ options ||= {}
63
63
 
64
- ::Xqsr3::Diagnostics::ExceptionUtilities.raise_with_options(*args, **(options.merge({ :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 => 1})))
65
- end
64
+ ::Xqsr3::Diagnostics::ExceptionUtilities.raise_with_options(*args, **(options.merge({ :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 => 1})))
65
+ end
66
66
  end # module Kernel
67
67
 
68
68
  # ############################## end of file ############################# #
@@ -1,3 +1,4 @@
1
1
 
2
+ require 'xqsr3/extensions/kernel/integer'
2
3
  require 'xqsr3/extensions/kernel/raise_with_options'
3
4
 
@@ -3,6 +3,6 @@ require 'xqsr3/string_utilities/ends_with'
3
3
 
4
4
  class String
5
5
 
6
- include ::Xqsr3::StringUtilities::EndsWith
6
+ include ::Xqsr3::StringUtilities::EndsWith
7
7
  end # class String
8
8