more_ruby 0.2.4 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86a75923546e29d00558a11340c8f9bf3418dce9f1ab893b7731ca496a7c6211
4
- data.tar.gz: cbf90660e124bb730ef57fc86d2dac9465041bd81d39641977c7902e7736dfe4
3
+ metadata.gz: 7c2d57dc39204b8f8cc55cd498e692f06a274c5166f2baf2613d202b83b38caa
4
+ data.tar.gz: 04b219c9e82649395391a9c45aabd2b49e284483571c5d44e2789779f1c50cf9
5
5
  SHA512:
6
- metadata.gz: ec4335955a25e39f62c120caa328e0bcc91cfc8720c8b7cb10c1994c4d7c1776981beec50d1ac0a379b191d183ce3a3565fe9102bcb1ea4d51f194403d0314f5
7
- data.tar.gz: 6f7262164329e748911c331cce53a389f9eef5b803c8b4c0ac9b46348ed4cd0df4ce2e51f58c3362c188fd043048187e4fe7369e427f53d0ddad69b50f0d1354
6
+ metadata.gz: bef9b6bc5daa81b8ba4c7948662522dc01d96d2f3c4fe610e9eb45d329fbe57c0cd9cbf53f6cc5eb991f330517191dd624dbe32237b7f65a68f2b5bb148ee16f
7
+ data.tar.gz: a2e0b6230bab19145e76fd0a892ebbd82c2c790ad4a73e4070c45e175ed621f34a2a36cac4c8690419f7b81d54855670f38fbfba3da4e2d579cb7aaa69179811
data/README.md CHANGED
@@ -2,47 +2,54 @@ A very simple gem that adds some methods to some Ruby standard classes, e.g. <ar
2
2
 
3
3
  Simply require the gem ( require "more_ruby" ) and the additional methods will be available.
4
4
 
5
- # New instance methods #
5
+ # New instance methods
6
6
 
7
7
  ## Array
8
- :all_instance_of?, :all_kind_of?, :av, :delete_random, :include_any?, :insert_flat, :mean, :modulo_fetch, :peach, :random, :random_index, :random_insert, :random_move, :stringify_all_values_deep, :sum, :wrap_fetch
9
8
 
10
- ## Fixnum
11
- :digit_count, :format_with_thousands_delimiter, :num_to_letter, :signif
9
+ :all_instance_of?, :all_kind_of?, :av, :delete_random, :include_any?, :insert_flat, :mean, :modulo_fetch, :peach, :random, :random_index, :random_insert, :random_move, :stringify_all_values_deep, :sum, :wrap_fetch
12
10
 
13
11
  ## Float
12
+
14
13
  :format_with_thousands_delimiter, :signif
15
14
 
16
15
  ## Hash
16
+
17
17
  :all_keys, :all_values, :delete_random, :peach, :random_key, :random_pair, :random_value, :remove_empty_fields, :sort_deep, :stringify_all_values_deep, :strip_hash_of_keys, :to_a_deep, :to_xml
18
18
 
19
19
  ## Integer
20
- :digit_count, :format_with_thousands_delimiter, :signif
20
+
21
+ :digit_count, :format_with_thousands_delimiter, :num_to_letter, :signif
21
22
 
22
23
  ## NilClass
24
+
23
25
  :empty?
24
26
 
25
27
  ## Numeric
28
+
26
29
  :format_with_thousands_delimiter
27
30
 
28
31
  ## String
32
+
29
33
  :append, :camelcase, :capitalize_all, :capitalize_first_letter_only, :escape, :escape_whitespace, :extract_values_from_xml_string, :formatted_number, :index_of_last_capital, :invert_case, :is_hex?, :is_integer?, :join, :pascalcase, :prefix_lines, :random_case, :snakecase, :snakecase_and_downcase, :snakecase_non_alpha, :to_bool, :unindent
30
34
 
31
35
  ## Time
36
+
32
37
  :is_after?, :is_before?, :is_within?, :remove_subseconds
33
38
 
34
- # New singleton methods #
39
+ # New singleton methods
35
40
 
36
41
  ## FalseClass
42
+
37
43
  :maybe?, :random
38
44
 
39
45
  ## File
46
+
40
47
  :basename_no_ext
41
48
 
42
49
  ## TrueClass
43
- :maybe?, :random
44
50
 
51
+ :maybe?, :random
45
52
 
46
- # New functionality #
53
+ # New functionality
47
54
 
48
- Adds :sup method to Object, allowing 'sup.[parent class method]' calls
55
+ Adds :sup method to Object, allowing 'sup.[parent class method]' calls
@@ -1,10 +1,11 @@
1
1
 
2
- class Fixnum
2
+ # Fixnum is deprecated, favouring Integer
3
+ # class Fixnum
3
4
 
4
- # Converts the number (1 <= x <= 26) to a letter
5
- # 1 => A, 9 => I, 0 has no corresponding letter
6
- def num_to_letter
7
- raise "Do not call num_to_letter with a number that is not between 1 and 26" unless self >= 1 && self <= 26
8
- (self.to_i + 64).chr
9
- end
10
- end
5
+ # # Converts the number (1 <= x <= 26) to a letter
6
+ # # 1 => A, 9 => I, 0 has no corresponding letter
7
+ # def num_to_letter
8
+ # raise "Do not call num_to_letter with a number that is not between 1 and 26" unless self >= 1 && self <= 26
9
+ # (self.to_i + 64).chr
10
+ # end
11
+ # end
@@ -17,4 +17,11 @@ class Integer
17
17
  m = (num_digits - 1) - Math.log10(self.abs).floor
18
18
  BigDecimal.new(((self * 10 ** m).round * 10 ** (-1 * m)).to_s).to_s('F').gsub(/\.0*$/,"").to_i
19
19
  end
20
+
21
+ # Converts the number (1 <= x <= 26) to a letter
22
+ # 1 => A, 9 => I, 0 has no corresponding letter
23
+ def num_to_letter
24
+ raise "Do not call num_to_letter with a number that is not between 1 and 26" unless self >= 1 && self <= 26
25
+ (self.to_i + 64).chr
26
+ end
20
27
  end
data/test/test_array.rb CHANGED
@@ -146,13 +146,11 @@ class TestArray < Test::Unit::TestCase
146
146
 
147
147
  b = (1 .. 4).to_a
148
148
  assert(b.all_kind_of?(Numeric), ".all_kind_of? returned false when the array's contents were all subclasses of the questioned class")
149
- assert(b.all_kind_of?(Integer), ".all_kind_of? returned false when the array's contents were all subclasses of the questioned class")
150
- assert(b.all_kind_of?(Fixnum), ".all_kind_of? returned false when the array's contents were all instances of the questioned class")
149
+ assert(b.all_kind_of?(Integer), ".all_kind_of? returned false when the array's contents were all instances of the questioned class")
151
150
 
152
151
  b.insert(2, 2.0)
153
152
  assert(b.all_kind_of?(Numeric), ".all_kind_of? returned false when the array's contents were all subclasses of the questioned class")
154
153
  assert_false(b.all_kind_of?(Integer), ".all_kind_of? returned true when there were distinctly different types in the array")
155
- assert_false(b.all_kind_of?(Fixnum), ".all_kind_of? returned true when there were distinctly different types in the array")
156
154
  end
157
155
 
158
156
 
@@ -163,8 +161,7 @@ class TestArray < Test::Unit::TestCase
163
161
 
164
162
  b = (1 .. 4).to_a
165
163
  assert_false(b.all_instance_of?(Numeric), ".all_instance_of? returned true when the array's contents were all subclasses of the questioned class")
166
- assert_false(b.all_instance_of?(Integer), ".all_instance_of? returned true when the array's contents were all subclasses of the questioned class")
167
- assert(b.all_instance_of?(Fixnum), ".all_instance_of? returned false when the array's contents were all instances of the questioned class")
164
+ assert(b.all_instance_of?(Integer), ".all_instance_of? returned false when the array's contents were all instances of the questioned class")
168
165
 
169
166
  b.insert(2, 2.0)
170
167
  assert_false(b.all_instance_of?(Numeric), ".all_instance_of? returned true when the array's contents were all subclasses of the questioned class")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: more_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Morrisby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2022-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A very simple gem that adds some methods to some Ruby standard classes,
14
14
  e.g. <array>.include_any?, <array>.delete_random, etc.\n\n Simply require the gem
@@ -16,12 +16,11 @@ description: " A very simple gem that adds some methods to some Ruby standard c
16
16
  New instance methods #\n\n ## Array\n :all_instance_of?, :all_kind_of?, :av, :delete_random,
17
17
  :include_any?, :insert_flat, :mean, :modulo_fetch, :peach, :random, :random_index,
18
18
  :random_insert, :random_move, :stringify_all_values_deep, :sum, :wrap_fetch\n \n
19
- \ ## Fixnum\n :digit_count, :format_with_thousands_delimiter, :num_to_letter, :signif\n
20
- \ \n ## Float\n :format_with_thousands_delimiter, :signif\n \n ## Hash\n :all_keys,
19
+ \ ## Float\n :format_with_thousands_delimiter, :signif\n \n ## Hash\n :all_keys,
21
20
  :all_values, :delete_random, :peach, :random_key, :random_pair, :random_value, :remove_empty_fields,
22
21
  :sort_deep, :stringify_all_values_deep, :strip_hash_of_keys, :to_a_deep, :to_xml\n
23
- \ \n ## Integer\n :digit_count, :format_with_thousands_delimiter, :signif\n \n
24
- \ ## NilClass\n :empty?\n \n ## Numeric\n :format_with_thousands_delimiter\n
22
+ \ \n ## Integer\n :digit_count, :format_with_thousands_delimiter, :num_to_letter,
23
+ :signif\n \n ## NilClass\n :empty?\n \n ## Numeric\n :format_with_thousands_delimiter\n
25
24
  \ \n ## String\n :append, :camelcase, :camelcase_to_snakecase, :capitalize_all,
26
25
  :capitalize_first_letter_only, :escape, :escape_whitespace, :extract_values_from_xml_string,
27
26
  :formatted_number, :index_of_last_capital, :invert_case, :is_hex?, :is_integer?,
@@ -69,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
68
  requirements:
70
69
  - - ">="
71
70
  - !ruby/object:Gem::Version
72
- version: '1.9'
71
+ version: '2.4'
73
72
  required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - ">="