diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-15 18:35:13 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-15 18:35:13 +0900 |
| commit | 6b457d2c006c333bfdc1328ecc73db7e63a6aca5 (patch) | |
| tree | d4175aeefd1bf78893e21dda70615127594ad29f /mrbgems/mruby-string-ext | |
| parent | c779413df39ef7d96583bda08104491c55049fad (diff) | |
| parent | bec4d053400c3a11c8efd68c3e8bd5ea4a0bcc54 (diff) | |
| download | mruby-6b457d2c006c333bfdc1328ecc73db7e63a6aca5.tar.gz mruby-6b457d2c006c333bfdc1328ecc73db7e63a6aca5.zip | |
Merge branch 'work_for_merge' of https://github.com/zubycz/mruby into zubycz-work_for_merge
Diffstat (limited to 'mrbgems/mruby-string-ext')
| -rw-r--r-- | mrbgems/mruby-string-ext/mrblib/string.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index 2e076f485..7544ac8f4 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -443,4 +443,27 @@ class String end self end + + def __upto_endless(&block) + return to_enum(:__upto_endless) unless block + + len = self.length + # both edges are all digits + bi = self.to_i(10) + if bi > 0 or bi == "0"*len + while true + s = bi.to_s + s = s.rjust(len, "0") if s.length < len + yield s + bi += 1 + end + return self + end + bs = self + while true + yield bs + bs = bs.succ + end + self + end end |
