Sha256: 547b74c66b1f621745b4385f1c7a48a8d997fe2d694804dd4345bac3b8b8a996
Contents?: true
Size: 1.96 KB
Versions: 7
Compression:
Stored size: 1.96 KB
Contents
# Monetize [](http://badge.fury.io/rb/monetize) [](https://travis-ci.org/RubyMoney/monetize) [](https://codeclimate.com/github/RubyMoney/monetize) [](https://coveralls.io/r/RubyMoney/monetize) [](https://gemnasium.com/RubyMoney/monetize) [](http://opensource.org/licenses/MIT) A library for converting various objects into `Money` objects. ## Installation Add this line to your application's Gemfile: gem 'monetize' And then execute: $ bundle Or install it yourself as: $ gem install monetize ## Usage ```ruby Monetize.parse("USD 100") == Money.new(100_00, "USD") Monetize.parse("EUR 100") == Money.new(100_00, "EUR") Monetize.parse("GBP 100") == Money.new(100_00, "GBP") "100".to_money == Money.new(100_00, "USD") ``` Optionally, enable the ability to assume the currency from a passed symbol. Otherwise, currency symbols will be ignored, and USD used as the default currency: ```ruby Monetize.parse("£100") == Money.new(100_00, "USD") Monetize.assume_from_symbol = true Monetize.parse("£100") == Money.new(100_00, "GBP") "€100".to_money == Money.new(100_00, "EUR") ``` Monetize can also parse a list of values, returning an array-like object ([Monetize::Collection](lib/collection.rb)): ```ruby Monetize.parse_collection("€80/$100") == [Money.new(80_00, "EUR"), Money.new(100_00, "USD")] Monetize.parse_collection("€80, $100") == [Money.new(80_00, "EUR"), Money.new(100_00, "USD")] # The #range? method detects the presence of a hyphen Monetize.parse_collection("€80-$100").range? == true ``` ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
Version data entries
7 entries across 7 versions & 2 rubygems