money
Version, currently master branch1 version
- master branchlatestNov 13, 2016
github.com/charlie-hadden/crystal-money
Money library for crystal
2 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
money:
github: charlie-hadden/crystal-money
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Charlie Hadden
Dependencies
This version declares no dependencies.
README
crystal-money
A crystal library for handing money and currency, heavily influenced by the great RubyMoney gem for Ruby. The interface is intended to be similar but not necessarily the same.
Installation
Add this to your application's shard.yml:
dependencies:
money:
github: charlie-hadden/crystal-money
Usage
require "money"
# Basic usage
money = Money.new(1000, "USD")
money.fractional #=> 1000
money.currency #=> Money::Currency.find("USD")
money.amount #=> BigFloat.new("10.00")
money.to_s #=> "10.00"
# Comparisons
Money.new(1000, "USD") == Money.new(1000, "USD") #=> true
Money.new(1000, "USD") == Money.new(1000, "GBP") #=> false
Money.new(1000, "USD") == Money.new(5000, "USD") #=> false
Money.new(1000, "USD") <= Money.new(5000, "USD") #=> true
# Arithmetic
Money.new(1000, "USD") + Money.new(2000, "USD") #=> Money.new(3000, "USD")
Money.new(3000, "USD") - Money.new(2000, "USD") #=> Money.new(1000, "USD")
Money.new(3000, "USD") * 3 #=> Money.new(9000, "USD")
# Formatting
Money.new(1000, "USD").format #=> "$10.00"
Money.new(1000, "GBP").format #=> "£10.00"
Money.new(1000, "EUR").format #=> "€10.00"
# Currency conversions
Money.new(1000, "USD").exchange_to("GBP") #=> Money.new(converted_value, "GBP")
Contributing
- Fork it ( https://github.com/charlie-hadden/crystal-money/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- charlie-hadden Charlie Hadden - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Nov 13, 2016
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/charlie-hadden/crystal-money
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1