Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

RMB is a gem helps you generate money in Chinese Yuan. 生成人民币大写金额

Resources

License

Packages

No packages published
You can’t perform that action at this time.