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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/lib/render/text/helper/float.rb +2 -2
- data/lib/render/text/helper/string.rb +10 -0
- data/lib/render/text/helper/version.rb +1 -1
- data/sig/string.rbs +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1953be6530d232e70bdf8669f1c222a4bfd71d472098b1b00c04ecaaa1a6d59e
|
|
4
|
+
data.tar.gz: 7d471ee6d810d1f16943d6c26374d85d72e477e15f35d6a4ec7888422cdb8b8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e44425ae9e4139360b0f280bb8d82c72df2facc44c83bcc110a8b97bda48f8c9587d53e392b230d820f3af1630cd8b23597dc0ca970ced0e58c1fc020e7ba6c
|
|
7
|
+
data.tar.gz: 6f5b67dcc4339dbef74220aea965e2676dd771266d5b8e4f78c716f97b98a4e8f41da3c0f2930736c99faa4853b4db534498e01297a38f3fd4561a952dc0185f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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.
|
|
@@ -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
|
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
|