pred 0.1.0 → 0.1.1
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/README.md +3 -0
- data/lib/pred/version.rb +1 -1
- data/lib/pred.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5512db6a131d69919db2723534c455d9d24dcd17
|
|
4
|
+
data.tar.gz: 7909c40ef0a5038aa0f4e4d158cbcc7fae24c3d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3520b85d17989e4a6f99df6555e2c4c4dc2142e3c01e6dc2b3fe13cd35f1d2b5642f70bd65c8723d57595bea8e86dca3f835dbbba24fe0f4ab6d00e04df28a5a
|
|
7
|
+
data.tar.gz: a5083e4f3704021cbb29569c7cd6d528f6e3b6f09e4159a3b9ac97684f150e056a09ff607265acbd4dd53670c04a1ca7a5e9e2cd147785012f6104aee715470f
|
data/README.md
CHANGED
|
@@ -49,6 +49,9 @@ Now we have a balance of force in the ruby universe as `#pred` is the ying of th
|
|
|
49
49
|
The name `pred` is shorthand for predecessor as `succ` is shorthand for successor.
|
|
50
50
|
If you create the method `#succ` on one of your classes, you should also create its counterpart `#pred`.
|
|
51
51
|
|
|
52
|
+
## Revision History
|
|
53
|
+
* Version 0.1.1 fixed bug on edge case 'a'.pred
|
|
54
|
+
|
|
52
55
|
## Development
|
|
53
56
|
|
|
54
57
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/pred/version.rb
CHANGED
data/lib/pred.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Pred
|
|
|
26
26
|
('0'..'9').cover? ch
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def self.count_digit?(ch)
|
|
29
|
+
def self.count_digit?(ch) # deprecate this ... not used anywhere
|
|
30
30
|
('0'..'9').cover? ch
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -77,6 +77,16 @@ module Pred
|
|
|
77
77
|
return false
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
def self.lone_bottom?(str) # 'a'.pred etc broken
|
|
81
|
+
while !letter_digit?(str[-1])
|
|
82
|
+
str = str[0..-2]
|
|
83
|
+
return false if str.empty?
|
|
84
|
+
end
|
|
85
|
+
if "aA0".include? str[-1]
|
|
86
|
+
return true unless decrements?(str[0..-2])
|
|
87
|
+
end
|
|
88
|
+
return false
|
|
89
|
+
end
|
|
80
90
|
|
|
81
91
|
# def self.inc(ch)
|
|
82
92
|
# (ch.ord+1).chr(Encoding::UTF_8)
|
|
@@ -174,6 +184,7 @@ module Pred
|
|
|
174
184
|
return "" if str.ord==0
|
|
175
185
|
end
|
|
176
186
|
return str[0..-2] + dec(str[-1]) unless decrements?(str)
|
|
187
|
+
return str[0..-2] + dec(str[-1]) if lone_bottom?(str)
|
|
177
188
|
return rcur_decrement_string(str, ref, str.length-1)
|
|
178
189
|
end
|
|
179
190
|
end
|