chars 0.2.3 → 0.2.4
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 +7 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +76 -48
- data/Rakefile +1 -1
- data/chars.gemspec +1 -0
- data/gemspec.yml +8 -2
- data/lib/chars/char_set.rb +68 -110
- data/lib/chars/chars.rb +54 -18
- data/lib/chars/extensions/integer.rb +34 -17
- data/lib/chars/extensions/string.rb +34 -17
- data/lib/chars/version.rb +1 -1
- data/spec/char_set_spec.rb +200 -91
- metadata +13 -9
data/lib/chars/chars.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'chars/char_set'
|
2
4
|
|
3
5
|
module Chars
|
@@ -39,7 +41,7 @@ module Chars
|
|
39
41
|
]
|
40
42
|
|
41
43
|
# The space character set
|
42
|
-
SPACE = CharSet
|
44
|
+
SPACE = CharSet[' ', "\f", "\n", "\r", "\t", "\v"]
|
43
45
|
|
44
46
|
# The set of printable characters (not including spaces)
|
45
47
|
VISIBLE = ALPHA_NUMERIC | CharSet[
|
@@ -66,7 +68,9 @@ module Chars
|
|
66
68
|
# @return [CharSet]
|
67
69
|
# The decimal-digit character set.
|
68
70
|
#
|
69
|
-
|
71
|
+
# @see NUMERIC
|
72
|
+
#
|
73
|
+
def self.numeric
|
70
74
|
NUMERIC
|
71
75
|
end
|
72
76
|
|
@@ -76,7 +80,9 @@ module Chars
|
|
76
80
|
# @return [CharSet]
|
77
81
|
# The octal-digit character set.
|
78
82
|
#
|
79
|
-
|
83
|
+
# @see OCTAL
|
84
|
+
#
|
85
|
+
def self.octal
|
80
86
|
OCTAL
|
81
87
|
end
|
82
88
|
|
@@ -86,7 +92,9 @@ module Chars
|
|
86
92
|
# @return [CharSet]
|
87
93
|
# The upper-case hexadecimal character set.
|
88
94
|
#
|
89
|
-
|
95
|
+
# @see UPPERCASE_HEXADECIMAL
|
96
|
+
#
|
97
|
+
def self.uppercase_hexadecimal
|
90
98
|
UPPERCASE_HEXADECIMAL
|
91
99
|
end
|
92
100
|
|
@@ -96,7 +104,9 @@ module Chars
|
|
96
104
|
# @return [CharSet]
|
97
105
|
# The lower-case hexadecimal character set.
|
98
106
|
#
|
99
|
-
|
107
|
+
# @see LOWERCASE_HEXADECIMAL
|
108
|
+
#
|
109
|
+
def self.lowercase_hexadecimal
|
100
110
|
LOWERCASE_HEXADECIMAL
|
101
111
|
end
|
102
112
|
|
@@ -106,7 +116,9 @@ module Chars
|
|
106
116
|
# @return [CharSet]
|
107
117
|
# The hexadecimal character set.
|
108
118
|
#
|
109
|
-
|
119
|
+
# @see HEXADECIMAL
|
120
|
+
#
|
121
|
+
def self.hexadecimal
|
110
122
|
HEXADECIMAL
|
111
123
|
end
|
112
124
|
|
@@ -116,7 +128,9 @@ module Chars
|
|
116
128
|
# @return [CharSet]
|
117
129
|
# The upper-case alphabetic character set.
|
118
130
|
#
|
119
|
-
|
131
|
+
# @see UPPERCASE_ALPHA
|
132
|
+
#
|
133
|
+
def self.uppercase_alpha
|
120
134
|
UPPERCASE_ALPHA
|
121
135
|
end
|
122
136
|
|
@@ -126,7 +140,9 @@ module Chars
|
|
126
140
|
# @return [CharSet]
|
127
141
|
# The lower-case alphabetic character set.
|
128
142
|
#
|
129
|
-
|
143
|
+
# @see LOWERCASE_ALPHA
|
144
|
+
#
|
145
|
+
def self.lowercase_alpha
|
130
146
|
LOWERCASE_ALPHA
|
131
147
|
end
|
132
148
|
|
@@ -136,7 +152,9 @@ module Chars
|
|
136
152
|
# @return [CharSet]
|
137
153
|
# The alphabetic character set.
|
138
154
|
#
|
139
|
-
|
155
|
+
# @see ALPHA
|
156
|
+
#
|
157
|
+
def self.alpha
|
140
158
|
ALPHA
|
141
159
|
end
|
142
160
|
|
@@ -146,7 +164,9 @@ module Chars
|
|
146
164
|
# @return [CharSet]
|
147
165
|
# The alpha-numeric character set.
|
148
166
|
#
|
149
|
-
|
167
|
+
# @see ALPHA_NUMERIC
|
168
|
+
#
|
169
|
+
def self.alpha_numeric
|
150
170
|
ALPHA_NUMERIC
|
151
171
|
end
|
152
172
|
|
@@ -156,7 +176,9 @@ module Chars
|
|
156
176
|
# @return [CharSet]
|
157
177
|
# The punctuation character set.
|
158
178
|
#
|
159
|
-
|
179
|
+
# @see PUNCTUATION
|
180
|
+
#
|
181
|
+
def self.punctuation
|
160
182
|
PUNCTUATION
|
161
183
|
end
|
162
184
|
|
@@ -166,7 +188,9 @@ module Chars
|
|
166
188
|
# @return [CharSet]
|
167
189
|
# The symbolic character set.
|
168
190
|
#
|
169
|
-
|
191
|
+
# @see SYMBOLS
|
192
|
+
#
|
193
|
+
def self.symbols
|
170
194
|
SYMBOLS
|
171
195
|
end
|
172
196
|
|
@@ -176,7 +200,9 @@ module Chars
|
|
176
200
|
# @return [CharSet]
|
177
201
|
# The white-space character set.
|
178
202
|
#
|
179
|
-
|
203
|
+
# @see SPACE
|
204
|
+
#
|
205
|
+
def self.space
|
180
206
|
SPACE
|
181
207
|
end
|
182
208
|
|
@@ -186,7 +212,9 @@ module Chars
|
|
186
212
|
# @return [CharSet]
|
187
213
|
# The visible character set.
|
188
214
|
#
|
189
|
-
|
215
|
+
# @see VISIBLE
|
216
|
+
#
|
217
|
+
def self.visible
|
190
218
|
VISIBLE
|
191
219
|
end
|
192
220
|
|
@@ -196,7 +224,9 @@ module Chars
|
|
196
224
|
# @return [CharSet]
|
197
225
|
# The printable character set.
|
198
226
|
#
|
199
|
-
|
227
|
+
# @see PRINTABLE
|
228
|
+
#
|
229
|
+
def self.printable
|
200
230
|
PRINTABLE
|
201
231
|
end
|
202
232
|
|
@@ -206,7 +236,9 @@ module Chars
|
|
206
236
|
# @return [CharSet]
|
207
237
|
# The control-character character set.
|
208
238
|
#
|
209
|
-
|
239
|
+
# @see CONTROL
|
240
|
+
#
|
241
|
+
def self.control
|
210
242
|
CONTROL
|
211
243
|
end
|
212
244
|
|
@@ -216,7 +248,9 @@ module Chars
|
|
216
248
|
# @return [CharSet]
|
217
249
|
# The signed ASCII character set.
|
218
250
|
#
|
219
|
-
|
251
|
+
# @see SIGNED_ASCII
|
252
|
+
#
|
253
|
+
def self.signed_ascii
|
220
254
|
SIGNED_ASCII
|
221
255
|
end
|
222
256
|
|
@@ -226,7 +260,9 @@ module Chars
|
|
226
260
|
# @return [CharSet]
|
227
261
|
# The ASCII character set.
|
228
262
|
#
|
229
|
-
|
263
|
+
# @see ASCII
|
264
|
+
#
|
265
|
+
def self.ascii
|
230
266
|
ASCII
|
231
267
|
end
|
232
268
|
end
|
@@ -8,7 +8,8 @@ class Integer
|
|
8
8
|
# @return [Boolean]
|
9
9
|
# Specifies whether the byte belongs to the decimal-digit character set.
|
10
10
|
#
|
11
|
-
# @see Chars
|
11
|
+
# @see Chars::NUMERIC
|
12
|
+
# @see Chars::CharSet#include_byte?
|
12
13
|
#
|
13
14
|
def numeric?
|
14
15
|
Chars::NUMERIC.include_byte?(self)
|
@@ -20,7 +21,8 @@ class Integer
|
|
20
21
|
# @return [Boolean]
|
21
22
|
# Specifies whether the byte belongs to the octal-digit character set.
|
22
23
|
#
|
23
|
-
# @see Chars
|
24
|
+
# @see Chars::OCTAL
|
25
|
+
# @see Chars::CharSet#include_byte?
|
24
26
|
#
|
25
27
|
def octal?
|
26
28
|
Chars::OCTAL.include_byte?(self)
|
@@ -34,7 +36,8 @@ class Integer
|
|
34
36
|
# Specifies whether the byte belongs to the upper-case hexadecimal
|
35
37
|
# character set.
|
36
38
|
#
|
37
|
-
# @see Chars
|
39
|
+
# @see Chars::UPPERCASE_HEXADECIMAL
|
40
|
+
# @see Chars::CharSet#include_byte?
|
38
41
|
#
|
39
42
|
def uppercase_hex?
|
40
43
|
Chars::UPPERCASE_HEXADECIMAL.include_byte?(self)
|
@@ -48,7 +51,8 @@ class Integer
|
|
48
51
|
# Specifies whether the byte belongs to the lower-case hexadecimal
|
49
52
|
# character set.
|
50
53
|
#
|
51
|
-
# @see Chars
|
54
|
+
# @see Chars::LOWERCASE_HEXADECIMAL
|
55
|
+
# @see Chars::CharSet#include_byte?
|
52
56
|
#
|
53
57
|
def lowercase_hex?
|
54
58
|
Chars::LOWERCASE_HEXADECIMAL.include_byte?(self)
|
@@ -60,7 +64,8 @@ class Integer
|
|
60
64
|
# @return [Boolean]
|
61
65
|
# Specifies whether the byte belongs to the hexadecimal character set.
|
62
66
|
#
|
63
|
-
# @see Chars
|
67
|
+
# @see Chars::HEXADECIMAL
|
68
|
+
# @see Chars::CharSet#include_byte?
|
64
69
|
#
|
65
70
|
def hex?
|
66
71
|
Chars::HEXADECIMAL.include_byte?(self)
|
@@ -74,7 +79,8 @@ class Integer
|
|
74
79
|
# Specifies whether the byte belongs to the upper-case alphabetic
|
75
80
|
# character set.
|
76
81
|
#
|
77
|
-
# @see Chars
|
82
|
+
# @see Chars::UPPERCASE_ALPHA
|
83
|
+
# @see Chars::CharSet#include_byte?
|
78
84
|
#
|
79
85
|
def uppercase_alpha?
|
80
86
|
Chars::UPPERCASE_ALPHA.include_byte?(self)
|
@@ -88,7 +94,8 @@ class Integer
|
|
88
94
|
# Specifies whether the byte belongs to the lower-case alphabetic
|
89
95
|
# character set.
|
90
96
|
#
|
91
|
-
# @see Chars
|
97
|
+
# @see Chars::LOWERCASE_ALPHA
|
98
|
+
# @see Chars::CharSet#include_byte?
|
92
99
|
#
|
93
100
|
def lowercase_alpha?
|
94
101
|
Chars::LOWERCASE_ALPHA.include_byte?(self)
|
@@ -100,7 +107,8 @@ class Integer
|
|
100
107
|
# @return [Boolean]
|
101
108
|
# Specifies whether the byte belongs to the alphabetic character set.
|
102
109
|
#
|
103
|
-
# @see Chars
|
110
|
+
# @see Chars::ALPHA
|
111
|
+
# @see Chars::CharSet#include_byte?
|
104
112
|
#
|
105
113
|
def alpha?
|
106
114
|
Chars::ALPHA.include_byte?(self)
|
@@ -112,7 +120,8 @@ class Integer
|
|
112
120
|
# @return [Boolean]
|
113
121
|
# Specifies whether the byte belongs to the alpha-numeric character set.
|
114
122
|
#
|
115
|
-
# @see Chars
|
123
|
+
# @see Chars::ALPHA_NUMERIC
|
124
|
+
# @see Chars::CharSet#include_byte?
|
116
125
|
#
|
117
126
|
def alpha_numeric?
|
118
127
|
Chars::ALPHA_NUMERIC.include_byte?(self)
|
@@ -124,7 +133,8 @@ class Integer
|
|
124
133
|
# @return [Boolean]
|
125
134
|
# Specifies whether the byte belongs to the punctuation character set.
|
126
135
|
#
|
127
|
-
# @see Chars
|
136
|
+
# @see Chars::PUNCTUATION
|
137
|
+
# @see Chars::CharSet#include_byte?
|
128
138
|
#
|
129
139
|
def punctuation?
|
130
140
|
Chars::PUNCTUATION.include_byte?(self)
|
@@ -136,7 +146,8 @@ class Integer
|
|
136
146
|
# @return [Boolean]
|
137
147
|
# Specifies whether the byte belongs to the symbolic character set.
|
138
148
|
#
|
139
|
-
# @see Chars
|
149
|
+
# @see Chars::SYMBOLS
|
150
|
+
# @see Chars::CharSet#include_byte?
|
140
151
|
#
|
141
152
|
def symbolic?
|
142
153
|
Chars::SYMBOLS.include_byte?(self)
|
@@ -148,7 +159,8 @@ class Integer
|
|
148
159
|
# @return [Boolean]
|
149
160
|
# Specifies whether the byte belongs to the white-space character set.
|
150
161
|
#
|
151
|
-
# @see Chars
|
162
|
+
# @see Chars::SPACE
|
163
|
+
# @see Chars::CharSet#include_byte?
|
152
164
|
#
|
153
165
|
def space?
|
154
166
|
Chars::SPACE.include_byte?(self)
|
@@ -160,7 +172,8 @@ class Integer
|
|
160
172
|
# @return [Boolean]
|
161
173
|
# Specifies whether the byte belongs to the visible character set.
|
162
174
|
#
|
163
|
-
# @see Chars
|
175
|
+
# @see Chars::VISIBLE
|
176
|
+
# @see Chars::CharSet#include_byte?
|
164
177
|
#
|
165
178
|
def visible?
|
166
179
|
Chars::VISIBLE.include_byte?(self)
|
@@ -172,7 +185,8 @@ class Integer
|
|
172
185
|
# @return [Boolean]
|
173
186
|
# Specifies whether the byte belongs to the printable character set.
|
174
187
|
#
|
175
|
-
# @see Chars
|
188
|
+
# @see Chars::PRINTABLE
|
189
|
+
# @see Chars::CharSet#include_byte?
|
176
190
|
#
|
177
191
|
def printable?
|
178
192
|
Chars::PRINTABLE.include_byte?(self)
|
@@ -185,7 +199,8 @@ class Integer
|
|
185
199
|
# Specifies whether the byte belongs to the control-character character
|
186
200
|
# set.
|
187
201
|
#
|
188
|
-
# @see Chars
|
202
|
+
# @see Chars::CONTROL
|
203
|
+
# @see Chars::CharSet#include_byte?
|
189
204
|
#
|
190
205
|
def control?
|
191
206
|
Chars::CONTROL.include_byte?(self)
|
@@ -197,7 +212,8 @@ class Integer
|
|
197
212
|
# @return [Boolean]
|
198
213
|
# Specifies whether the byte belongs to the signed-ASCII character set.
|
199
214
|
#
|
200
|
-
# @see Chars
|
215
|
+
# @see Chars::SIGNED_ASCII
|
216
|
+
# @see Chars::CharSet#include_byte?
|
201
217
|
#
|
202
218
|
def signed_ascii?
|
203
219
|
Chars::SIGNED_ASCII.include_byte?(self)
|
@@ -209,7 +225,8 @@ class Integer
|
|
209
225
|
# @return [Boolean]
|
210
226
|
# Specifies whether the byte belongs to the ASCII character set.
|
211
227
|
#
|
212
|
-
# @see Chars
|
228
|
+
# @see Chars::ASCII
|
229
|
+
# @see Chars::CharSet#include_byte?
|
213
230
|
#
|
214
231
|
def ascii?
|
215
232
|
Chars::ASCII.include_byte?(self)
|
@@ -9,7 +9,8 @@ class String
|
|
9
9
|
# Specifies whether the String belongs to the decimal-digit character
|
10
10
|
# set.
|
11
11
|
#
|
12
|
-
# @see Chars
|
12
|
+
# @see Chars::NUMERIC
|
13
|
+
# @see Chars::CharSet#===
|
13
14
|
#
|
14
15
|
def numeric?
|
15
16
|
Chars::NUMERIC === self
|
@@ -22,7 +23,8 @@ class String
|
|
22
23
|
# Specifies whether the String belongs to the octal-digit character
|
23
24
|
# set.
|
24
25
|
#
|
25
|
-
# @see Chars
|
26
|
+
# @see Chars::OCTAL
|
27
|
+
# @see Chars::CharSet#===
|
26
28
|
#
|
27
29
|
def octal?
|
28
30
|
Chars::OCTAL === self
|
@@ -36,7 +38,8 @@ class String
|
|
36
38
|
# Specifies whether the String belongs to the upper-case hexadecimal
|
37
39
|
# character set.
|
38
40
|
#
|
39
|
-
# @see Chars
|
41
|
+
# @see Chars::UPPERCASE_HEXADECIMAL
|
42
|
+
# @see Chars::CharSet#===
|
40
43
|
#
|
41
44
|
def uppercase_hex?
|
42
45
|
Chars::UPPERCASE_HEXADECIMAL === self
|
@@ -50,7 +53,8 @@ class String
|
|
50
53
|
# Specifies whether the String belongs to the lower-case hexadecimal
|
51
54
|
# character set.
|
52
55
|
#
|
53
|
-
# @see Chars
|
56
|
+
# @see Chars::LOWERCASE_HEXADECIMAL
|
57
|
+
# @see Chars::CharSet#===
|
54
58
|
#
|
55
59
|
def lowercase_hex?
|
56
60
|
Chars::LOWERCASE_HEXADECIMAL === self
|
@@ -62,7 +66,8 @@ class String
|
|
62
66
|
# @return [Boolean]
|
63
67
|
# Specifies whether the String belongs to the hexadecimal character set.
|
64
68
|
#
|
65
|
-
# @see Chars
|
69
|
+
# @see Chars::HEXADECIMAL
|
70
|
+
# @see Chars::CharSet#===
|
66
71
|
#
|
67
72
|
def hex?
|
68
73
|
Chars::HEXADECIMAL === self
|
@@ -76,7 +81,8 @@ class String
|
|
76
81
|
# Specifies whether the String belongs to the upper-case alphabetic
|
77
82
|
# character set.
|
78
83
|
#
|
79
|
-
# @see Chars
|
84
|
+
# @see Chars::UPPERCASE_ALPHA
|
85
|
+
# @see Chars::CharSet#===
|
80
86
|
#
|
81
87
|
def uppercase_alpha?
|
82
88
|
Chars::UPPERCASE_ALPHA === self
|
@@ -90,7 +96,8 @@ class String
|
|
90
96
|
# Specifies whether the String belongs to the lower-case alphabetic
|
91
97
|
# character set.
|
92
98
|
#
|
93
|
-
# @see Chars
|
99
|
+
# @see Chars::LOWERCASE_ALPHA
|
100
|
+
# @see Chars::CharSet#===
|
94
101
|
#
|
95
102
|
def lowercase_alpha?
|
96
103
|
Chars::LOWERCASE_ALPHA === self
|
@@ -102,7 +109,8 @@ class String
|
|
102
109
|
# @return [Boolean]
|
103
110
|
# Specifies whether the String belongs to the alphabetic character set.
|
104
111
|
#
|
105
|
-
# @see Chars
|
112
|
+
# @see Chars::ALPHA
|
113
|
+
# @see Chars::CharSet#===
|
106
114
|
#
|
107
115
|
def alpha?
|
108
116
|
Chars::ALPHA === self
|
@@ -116,7 +124,8 @@ class String
|
|
116
124
|
# Specifies whether the String belongs to the alpha-numeric character
|
117
125
|
# set.
|
118
126
|
#
|
119
|
-
# @see Chars
|
127
|
+
# @see Chars::ALPHA_NUMERIC
|
128
|
+
# @see Chars::CharSet#===
|
120
129
|
#
|
121
130
|
def alpha_numeric?
|
122
131
|
Chars::ALPHA_NUMERIC === self
|
@@ -128,7 +137,8 @@ class String
|
|
128
137
|
# @return [Boolean]
|
129
138
|
# Specifies whether the String belongs to the punctuation character set.
|
130
139
|
#
|
131
|
-
# @see Chars
|
140
|
+
# @see Chars::PUNCTUATION
|
141
|
+
# @see Chars::CharSet#===
|
132
142
|
#
|
133
143
|
def punctuation?
|
134
144
|
Chars::PUNCTUATION === self
|
@@ -140,7 +150,8 @@ class String
|
|
140
150
|
# @return [Boolean]
|
141
151
|
# Specifies whether the String belongs to the symbolic character set.
|
142
152
|
#
|
143
|
-
# @see Chars
|
153
|
+
# @see Chars::SYMBOLS
|
154
|
+
# @see Chars::CharSet#===
|
144
155
|
#
|
145
156
|
def symbolic?
|
146
157
|
Chars::SYMBOLS === self
|
@@ -152,7 +163,8 @@ class String
|
|
152
163
|
# @return [Boolean]
|
153
164
|
# Specifies whether the String belongs to the white-space character set.
|
154
165
|
#
|
155
|
-
# @see Chars
|
166
|
+
# @see Chars::SPACE
|
167
|
+
# @see Chars::CharSet#===
|
156
168
|
#
|
157
169
|
def space?
|
158
170
|
Chars::SPACE === self
|
@@ -164,7 +176,8 @@ class String
|
|
164
176
|
# @return [Boolean]
|
165
177
|
# Specifies whether the String belongs to the visible character set.
|
166
178
|
#
|
167
|
-
# @see Chars
|
179
|
+
# @see Chars::VISIBLE
|
180
|
+
# @see Chars::CharSet#===
|
168
181
|
#
|
169
182
|
def visible?
|
170
183
|
Chars::VISIBLE === self
|
@@ -176,7 +189,8 @@ class String
|
|
176
189
|
# @return [Boolean]
|
177
190
|
# Specifies whether the String belongs to the printable character set.
|
178
191
|
#
|
179
|
-
# @see Chars
|
192
|
+
# @see Chars::PRINTABLE
|
193
|
+
# @see Chars::CharSet#===
|
180
194
|
#
|
181
195
|
def printable?
|
182
196
|
Chars::PRINTABLE === self
|
@@ -190,7 +204,8 @@ class String
|
|
190
204
|
# Specifies whether the String belongs to the control-character
|
191
205
|
# character set.
|
192
206
|
#
|
193
|
-
# @see Chars
|
207
|
+
# @see Chars::CONTROL
|
208
|
+
# @see Chars::CharSet#===
|
194
209
|
#
|
195
210
|
def control?
|
196
211
|
Chars::CONTROL === self
|
@@ -203,7 +218,8 @@ class String
|
|
203
218
|
# Specifies whether the String belongs to the signed-ASCII character
|
204
219
|
# set.
|
205
220
|
#
|
206
|
-
# @see Chars
|
221
|
+
# @see Chars::SIGNED_ASCII
|
222
|
+
# @see Chars::CharSet#===
|
207
223
|
#
|
208
224
|
def signed_ascii?
|
209
225
|
Chars::SIGNED_ASCII === self
|
@@ -215,7 +231,8 @@ class String
|
|
215
231
|
# @return [Boolean]
|
216
232
|
# Specifies whether the String belongs to the ASCII character set.
|
217
233
|
#
|
218
|
-
# @see Chars
|
234
|
+
# @see Chars::ASCII
|
235
|
+
# @see Chars::CharSet#===
|
219
236
|
#
|
220
237
|
def ascii?
|
221
238
|
Chars::ASCII === self
|
data/lib/chars/version.rb
CHANGED