Module: YaKansuji::Formatter::Lawyer
- Defined in:
- lib/ya_kansuji/formatter/lawyer.rb
Overview
Formatter for Jpanese lawyer style kansuji
Class Method Summary collapse
Class Method Details
.call(num, _options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ya_kansuji/formatter/lawyer.rb', line 10 def call(num, = {}) return '0' if num.zero? ret = +'' chunks = Formatter.split_by_unit4(num) (chunks.size - 1).downto(0) do |idx4| i4 = chunks[idx4] next if i4.zero? unit4 = Formatter::UNIT4_UNITS[idx4] if i4 == 1 ret << "1#{unit4}" next end ret << ((i4 >= 1000 ? "#{i4.to_s[0]},#{i4.to_s[1..-1]}" : i4.to_s) + unit4) end ret end |