kanamei-keystone 0.0.4 → 0.0.8

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.
Files changed (2) hide show
  1. data/lib/keystone/string_util.rb +27 -2
  2. metadata +1 -1
@@ -1,7 +1,32 @@
1
1
  module Keystone
2
2
  class StringUtil
3
- def test
4
- "hello test"
3
+ def self.int_to_splitted_path(i_value,value_length,base_folder,suffix="")
4
+ file_name = Integer(i_value).to_s
5
+ raise "value_length must bigger than 0" if value_length < 1
6
+ raise 'i_value length is bigger than value_length' if file_name.size > value_length
7
+ file_name = file_name.rjust(value_length, '0')
8
+ new_path = base_folder.dup
9
+ group_regex = ""
10
+ i = value_length
11
+ group_cnt = 0
12
+ loop do
13
+ group_cnt += 1
14
+ if i > 2
15
+ group_regex << "(\\d\\d\\d)"
16
+ i -= 3
17
+ break if i < 1
18
+ else
19
+ group_regex = "(#{"\\d"*i})" + group_regex
20
+ break
21
+ end
22
+ end
23
+ file_name.gsub(/#{group_regex}/) do |hit|
24
+ 1.upto(group_cnt) do |i|
25
+ new_path << "/#{Regexp.last_match[i]}"
26
+ end
27
+ end
28
+ new_path << suffix if suffix != ""
29
+ return new_path
5
30
  end
6
31
  end
7
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanamei-keystone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kanamei