Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- app/models/jpp_customercode_transfer/zip_code_list.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.kanju2num(kan) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/jpp_customercode_transfer/zip_code_list.rb', line 45 def self.kanju2num(kan) nums = %w|〇 一 二 三 四 五 六 七 八 九| digits = %w|十 百 千| digits2 = %w|万 億 兆| pieces = kan.split(//) stack = 0 sum = 0 result = 0 while kan = pieces.shift if i = nums.index(kan) stack = i elsif i = digits.index(kan) stack = 1 if stack == 0 sum += stack * (10 ** (i + 1)) stack = 0 elsif i = digits2.index(kan) result += (sum + stack) * ( 10 ** ((i + 1) * 4)) sum = 0 stack = 0 end end result += sum + stack return result.to_s end |
Instance Method Details
#strip_hypen_behind_alphabet ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/jpp_customercode_transfer/zip_code_list.rb', line 25 def strip_hypen_behind_alphabet s2 = "" pos = 0 doFlag = true while doFlag break if pos > self.size pos2 = pos pos = self.index(/[A-Z]\-/, pos) unless pos s2 = s2 + self[pos2..-1] break end s2 = s2 + self[pos2..pos] pos = pos + 2 end #puts "strip_hypen_around_alphabet s2=#{s2}" return s2 end |
#strip_hypen_front_alphabet ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/jpp_customercode_transfer/zip_code_list.rb', line 7 def strip_hypen_front_alphabet s = "" c = 0 while true break if c > self.size c2 = c c = self.index(/\-[A-Z]/, c) unless c s = s + self[c2..-1] break end s = s + self[c2...c] c = c + 1 end return s end |