render-text-helper 0.4.1 → 0.4.2

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: b7cde7c2690826b2c8a735bb088254f4cac6e7fd818f3f2605cf16a5a1b82e3e
4
- data.tar.gz: 5e09fd32cbf9028e9d3ee0846a5f76dabd914302e369072c1faa815660fcc36b
3
+ metadata.gz: 1953be6530d232e70bdf8669f1c222a4bfd71d472098b1b00c04ecaaa1a6d59e
4
+ data.tar.gz: 7d471ee6d810d1f16943d6c26374d85d72e477e15f35d6a4ec7888422cdb8b8f
5
5
  SHA512:
6
- metadata.gz: 5551f2993778b2ef40550bf3d711ef011553bd08873a1cdea4c83ce6ae0e3da4a6c6bf37ec603d40f6dc4a483426c34471167a8ec74eade4c378a9439a9d3fa0
7
- data.tar.gz: 942d652b160aa69a4f91e41bd4122cf4d9a88ad66ee1b3e98e7db8dbf65c1301b0be46b2db5004bab73129432b21eb7cb0d9f903cf1262f0df6b58d2541b595b
6
+ metadata.gz: 1e44425ae9e4139360b0f280bb8d82c72df2facc44c83bcc110a8b97bda48f8c9587d53e392b230d820f3af1630cd8b23597dc0ca970ced0e58c1fc020e7ba6c
7
+ data.tar.gz: 6f5b67dcc4339dbef74220aea965e2676dd771266d5b8e4f78c716f97b98a4e8f41da3c0f2930736c99faa4853b4db534498e01297a38f3fd4561a952dc0185f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.2] - 2025-20-11
4
+
5
+ - Added to_letters_and_numbers method to string that removes all but letters and numbers
6
+
3
7
  ## [0.4.1] - 2025-14-10
4
8
 
5
9
  - Added add_percent_sign method that adds percentage to float
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- render-text-helper (0.4.1)
4
+ render-text-helper (0.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -76,6 +76,21 @@ Titleize for none rails project. It also removes unnecessary white spaces and co
76
76
  "Hello World!"
77
77
  ```
78
78
 
79
+ ### To Letters And Numbers
80
+
81
+ Strips all characters instead of letters, numbers and space.
82
+ It also trims spaces at the beginning and the end.
83
+ You have the option to disallow spaces as well.
84
+ This is good for common input like name, address, other standard writings.
85
+
86
+ ```ruby
87
+ ' A1!2@3#4$ 5%6^S7&8*9 F(0)-_=+Z|/?.>rlq<,*/ '.to_letters_and_numbers
88
+ "A1234 56S789 F0Zrlq"
89
+
90
+ ' A1!2@3#4$ 5%6^S7&8*9 F(0)-_=+Z|/?.>rlq<,*/ '.to_letters_and_numbers(allow_space: false)
91
+ "A123456S789F0Zrlq"
92
+ ```
93
+
79
94
  ### to yes no
80
95
 
81
96
  This function returns a string from a boolean to yes or no.
@@ -3,8 +3,8 @@
3
3
  # Added methods to float
4
4
  class Float
5
5
  def add_percent_sign
6
- return nil if self.nil?
6
+ return nil if nil?
7
7
 
8
- self.to_s.concat('%')
8
+ to_s.concat('%')
9
9
  end
10
10
  end
@@ -30,4 +30,14 @@ class String
30
30
 
31
31
  gsub('_', ' ').strip.split.map(&:capitalize).join(' ')
32
32
  end
33
+
34
+ def to_letters_and_numbers(allow_space: true)
35
+ return '' if self == ''
36
+
37
+ if allow_space
38
+ gsub(/[^a-zA-Z0-9 ]/, '').strip
39
+ else
40
+ gsub(/[^a-zA-Z0-9]/, '').strip
41
+ end
42
+ end
33
43
  end
@@ -3,7 +3,7 @@
3
3
  module Render
4
4
  module Text
5
5
  module Helper
6
- VERSION = '0.4.1'
6
+ VERSION = '0.4.2'
7
7
  end
8
8
  end
9
9
  end
data/sig/string.rbs CHANGED
@@ -1,6 +1,8 @@
1
1
  class String
2
2
  def escaped_newline_to_newline: -> String
3
3
  def limit_print:(limit: Integer, more_indicator: String, indicator_length: Integer) -> String
4
+
5
+ def to_letters_and_numbers:(allow_space: bool) -> String
4
6
  def to_smart_array:(separator: String | nil) -> [String]
5
7
  def to_titleize: -> String
6
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-text-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell