RMB is a gem helps you generate money in Chinese Yuan. 生成人民币大写金额
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
test
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
Gemfile
LICENSE.txt
README.md
Rakefile
rmb_chinese_yuan.gemspec

README.md

RMB

Gem Version Build Status Code Climate Test Coverage

RMB is a gem helps you generate money in Chinese Yuan.

Installation

Add this line to your application's Gemfile:

gem 'rmb_chinese_yuan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rmb_chinese_yuan

Usage

RMB.new(12345).convert              # => '壹万贰仟叁佰肆拾伍元'

# String argument is welcome
RMB.new('12345').convert            # => '壹万贰仟叁佰肆拾伍元'
RMB.new('1,234,567,890').convert    # => '壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾元'

# Decimal digits are supported
RMB.new(123.45).convert             # => '壹佰贰拾叁元肆角伍分'
RMB.new(0.55).convert               # => '伍角伍分'
RMB.new('.55').convert              # => '伍角伍分'

# Precision validates by 12 integers and 2 decimals
RMB.new('1234567890123').convert    # => ArgumentError: Integer part of money is longer than 12
RMB.new(1.155).convert              # => '壹元壹角伍分'

# Argument validation
RMB.new('hello mate').convert       # => ArgumentError: Not a valid money
RMB.new('-134').convert             # => ArgumentError: Not a valid money

License

The gem is available as open source under the terms of the MIT License.