[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7910":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},7910,"money","RubyMoney\u002Fmoney","RubyMoney","A Ruby Library for dealing with money and currency conversion.","http:\u002F\u002Frubymoney.github.io\u002Fmoney",null,"Ruby",2872,642,68,5,0,3,18,1,30.42,"MIT License",false,"main",true,[26,5,27],"exchange-rate","ruby","2026-06-12 02:01:46","# RubyMoney - Money\n\n[![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Fmoney.svg)](https:\u002F\u002Frubygems.org\u002Fgems\u002Fmoney)\n[![Ruby](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Factions\u002Fworkflows\u002Fruby.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Factions\u002Fworkflows\u002Fruby.yml)\n[![Inline docs](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs-github.io-green.svg)](https:\u002F\u002Frubymoney.github.io\u002Fmoney\u002F)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002FRubyMoney\u002Fmoney.svg)](https:\u002F\u002Fopensource.org\u002Flicense\u002FMIT)\n\n⚠️ Please read the [upgrade guides](#upgrade-guides) before upgrading to a new major version.\n\nIf you miss String parsing, check out the new [monetize gem](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmonetize).\n\n## Contributing\n\nSee the [Contribution Guidelines](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Fblob\u002Fmain\u002FCONTRIBUTING.md)\n\n## Introduction\n\nA Ruby Library for dealing with money and currency conversion.\n\n### Features\n\n- Provides a `Money` class which encapsulates all information about a certain\n  amount of money, such as its value and its currency.\n- Provides a `Money::Currency` class which encapsulates all information about\n  a monetary unit.\n- Represents monetary values as integers, in cents. This avoids floating point\n  rounding errors.\n- Represents currency as `Money::Currency` instances providing a high level of\n  flexibility.\n- Provides APIs for exchanging money from one currency to another.\n\n### Resources\n\n- [Website](https:\u002F\u002Frubymoney.github.io\u002Fmoney\u002F)\n- [API Documentation](https:\u002F\u002Fwww.rubydoc.info\u002Fgems\u002Fmoney\u002Fframes)\n- [Git Repository](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney)\n\n### Notes\n\n- Your app must use UTF-8 to function with this library. There are a\n  number of non-ASCII currency attributes.\n\n## Downloading\n\nInstall stable releases with the following command:\n\n    gem install money\n\nThe development version (hosted on Github) can be installed with:\n\n    git clone git:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney.git\n    cd money\n    rake install\n\n## Usage\n\n```ruby\nrequire 'money'\n\n# explicitly define locales\nI18n.config.available_locales = :en\nMoney.locale_backend = :i18n\n\n# 10.00 USD\nmoney = Money.from_cents(1000, \"USD\")\nmoney.cents     #=> 1000\nmoney.currency  #=> Currency.new(\"USD\")\n\n# Comparisons\nMoney.from_cents(1000, \"USD\") == Money.from_cents(1000, \"USD\")   #=> true\nMoney.from_cents(1000, \"USD\") == Money.from_cents(100, \"USD\")    #=> false\nMoney.from_cents(1000, \"USD\") == Money.from_cents(1000, \"EUR\")   #=> false\nMoney.from_cents(1000, \"USD\") != Money.from_cents(1000, \"EUR\")   #=> true\n\n# Arithmetic\nMoney.from_cents(1000, \"USD\") + Money.from_cents(500, \"USD\") == Money.from_cents(1500, \"USD\")\nMoney.from_cents(1000, \"USD\") - Money.from_cents(200, \"USD\") == Money.from_cents(800, \"USD\")\nMoney.from_cents(1000, \"USD\") \u002F 5                            == Money.from_cents(200, \"USD\")\nMoney.from_cents(1000, \"USD\") * 5                            == Money.from_cents(5000, \"USD\")\n\n# Unit to subunit conversions\nMoney.from_amount(5, \"USD\") == Money.from_cents(500, \"USD\")  # 5 USD\nMoney.from_amount(5, \"JPY\") == Money.from_cents(5, \"JPY\")    # 5 JPY\nMoney.from_amount(5, \"TND\") == Money.from_cents(5000, \"TND\") # 5 TND\n\n# Currency conversions\nsome_code_to_setup_exchange_rates\nMoney.from_cents(1000, \"USD\").exchange_to(\"EUR\") == Money.from_cents(some_value, \"EUR\")\n\n# Swap currency\nMoney.from_cents(1000, \"USD\").with_currency(\"EUR\") == Money.from_cents(1000, \"EUR\")\n\n# Formatting (see Formatting section for more options)\nMoney.from_cents(100, \"USD\").format #=> \"$1.00\"\nMoney.from_cents(100, \"GBP\").format #=> \"£1.00\"\nMoney.from_cents(100, \"EUR\").format #=> \"€1.00\"\n```\n\n## Currency\n\nCurrencies are consistently represented as instances of `Money::Currency`.\nThe most part of `Money` APIs allows you to supply either a `String` or a\n`Money::Currency`.\n\n```ruby\nMoney.from_cents(1000, \"USD\") == Money.from_cents(1000, Money::Currency.new(\"USD\"))\nMoney.from_cents(1000, \"EUR\").currency == Money::Currency.new(\"EUR\")\n```\n\nA `Money::Currency` instance holds all the information about the currency,\nincluding the currency symbol, name and much more.\n\n```ruby\ncurrency = Money.from_cents(1000, \"USD\").currency\ncurrency.iso_code     #=> \"USD\"\ncurrency.name         #=> \"United States Dollar\"\ncurrency.cents_based? #=> true\n```\n\nTo define a new `Money::Currency` use `Money::Currency.register` as shown\nbelow.\n\n```ruby\ncurr = {\n  priority:            1,\n  iso_code:            \"USD\",\n  iso_numeric:         \"840\",\n  name:                \"United States Dollar\",\n  symbol:              \"$\",\n  subunit:             \"Cent\",\n  subunit_to_unit:     100,\n  decimal_mark:        \".\",\n  thousands_separator: \",\"\n}\n\nMoney::Currency.register(curr)\n```\n\nThe pre-defined set of attributes includes:\n\n- `:priority` a numerical value you can use to sort\u002Fgroup the currency list\n- `:iso_code` the international 3-letter code as defined by the ISO 4217 standard\n- `:iso_numeric` the international 3-digit code as defined by the ISO 4217 standard\n- `:name` the currency name\n- `:symbol` the currency symbol (UTF-8 encoded)\n- `:subunit` the name of the fractional monetary unit\n- `:subunit_to_unit` the proportion between the unit and the subunit\n- `:decimal_mark` character between the whole and fraction amounts\n- `:thousands_separator` character between each thousands place\n\nAll attributes except `:iso_code` are optional. Some attributes, such as\n`:symbol`, are used by the Money class to print out a representation of the\nobject. Other attributes, such as `:name` or `:priority`, exist to provide a\nbasic API you can take advantage of to build your application.\n\n### :priority\n\nThe priority attribute is an arbitrary numerical value you can assign to the\n`Money::Currency` and use in sorting\u002Fgrouping operation.\n\nFor instance, let's assume your Rails application needs to render a currency\nselector like the one available\n[here](https:\u002F\u002Ffinance.yahoo.com\u002Fcurrency-converter\u002F). You can create a couple of\ncustom methods to return the list of major currencies and all currencies as\nfollows:\n\n```ruby\n# Returns an array of currency id where\n# priority \u003C 10\ndef major_currencies(hash)\n  hash.inject([]) do |array, (id, attributes)|\n    priority = attributes[:priority]\n    if priority && priority \u003C 10\n      array[priority] ||= []\n      array[priority] \u003C\u003C id\n    end\n    array\n  end.compact.flatten\nend\n\n# Returns an array of all currency id\ndef all_currencies(hash)\n  hash.keys\nend\n\nmajor_currencies(Money::Currency.table)\n# => [:usd, :eur, :gbp, :aud, :cad, :jpy]\n\nall_currencies(Money::Currency.table)\n# => [:aed, :afn, :all, ...]\n```\n\n### Default Currency\n\nA default currency is not set by default. If a default currency is not set, it will raise an error when you try to initialize a `Money` object without explicitly passing a currency or parse a string that does not contain a currency. You can set a default currency for your application by using:\n\n```ruby\nMoney.default_currency = Money::Currency.new(\"CAD\")\n```\n\nIf you use [Rails](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Ftree\u002Fmain#ruby-on-rails), then `config\u002Finitializers\u002Fmoney.rb` is a very good place to put this.\n\n### Currency Exponent\n\nThe exponent of a money value is the number of digits after the decimal\nseparator (which separates the major unit from the minor unit). See e.g.\n[ISO 4217](https:\u002F\u002Fwww.iso.org\u002Fiso-4217-currency-codes.html) for more\ninformation. You can find the exponent (as an `Integer`) by\n\n```ruby\nMoney::Currency.new(\"USD\").exponent  # => 2\nMoney::Currency.new(\"JPY\").exponent  # => 0\nMoney::Currency.new(\"MGA\").exponent  # => 1\n```\n\n### Currency Lookup\n\nTo find a given currency by ISO 4217 numeric code (three digits) you can do\n\n```ruby\nMoney::Currency.find_by_iso_numeric(978) #=> Money::Currency.new(:eur)\n```\n\n## Currency Exchange\n\nExchanging money is performed through an exchange bank object. The default\nexchange bank object requires one to manually specify the exchange rate. Here's\nan example of how it works:\n\n```ruby\nMoney.add_rate(\"USD\", \"CAD\", 1.24515)\nMoney.add_rate(\"CAD\", \"USD\", 0.803115)\n\nMoney.us_dollar(100).exchange_to(\"CAD\")  # => Money.from_cents(124, \"CAD\")\nMoney.ca_dollar(100).exchange_to(\"USD\")  # => Money.from_cents(80, \"USD\")\n```\n\nComparison and arithmetic operations work as expected:\n\n```ruby\nMoney.from_cents(1000, \"USD\") \u003C=> Money.from_cents(900, \"USD\")   # => 1; 9.00 USD is smaller\nMoney.from_cents(1000, \"EUR\") + Money.from_cents(10, \"EUR\") == Money.from_cents(1010, \"EUR\")\n\nMoney.add_rate(\"USD\", \"EUR\", 0.5)\nMoney.from_cents(1000, \"EUR\") + Money.from_cents(1000, \"USD\") == Money.from_cents(1500, \"EUR\")\n```\n\n### Exchange rate stores\n\nThe default bank is initialized with an in-memory store for exchange rates.\n\n```ruby\nMoney.default_bank = Money::Bank::VariableExchange.new(Money::RatesStore::Memory.new)\n```\n\nYou can pass your own store implementation, i.e. for storing and retrieving rates off a database, file, cache, etc.\n\n```ruby\nMoney.default_bank = Money::Bank::VariableExchange.new(MyCustomStore.new)\n```\n\nStores must implement the following interface:\n\n```ruby\n# Add new exchange rate.\n# @param [String] iso_from Currency ISO code. ex. 'USD'\n# @param [String] iso_to Currency ISO code. ex. 'CAD'\n# @param [Numeric] rate Exchange rate. ex. 0.0016\n#\n# @return [Numeric] rate.\ndef add_rate(iso_from, iso_to, rate); end\n\n# Get rate. Must be idempotent. i.e. adding the same rate must not produce duplicates.\n# @param [String] iso_from Currency ISO code. ex. 'USD'\n# @param [String] iso_to Currency ISO code. ex. 'CAD'\n#\n# @return [Numeric] rate.\ndef get_rate(iso_from, iso_to); end\n\n# Iterate over rate tuples (iso_from, iso_to, rate)\n#\n# @yieldparam iso_from [String] Currency ISO string.\n# @yieldparam iso_to [String] Currency ISO string.\n# @yieldparam rate [Numeric] Exchange rate.\n#\n# @return [Enumerator]\n#\n# @example\n#   store.each_rate do |iso_from, iso_to, rate|\n#     puts [iso_from, iso_to, rate].join\n#   end\ndef each_rate(&block); end\n\n# Wrap store operations in a thread-safe transaction\n# (or IO or Database transaction, depending on your implementation)\n#\n# @yield [n] Block that will be wrapped in transaction.\n#\n# @example\n#   store.transaction do\n#     store.add_rate('USD', 'CAD', 0.9)\n#     store.add_rate('USD', 'CLP', 0.0016)\n#   end\ndef transaction(&block); end\n\n# Serialize store and its content to make Marshal.dump work.\n#\n# Returns an array with store class and any arguments needed to initialize the store in the current state.\n\n# @return [Array] [class, arg1, arg2]\ndef marshal_dump; end\n```\n\nThe following example implements an `ActiveRecord` store to save exchange rates to a database.\n\n```ruby\n# rails g model exchange_rate from:string to:string rate:float\n\nclass ExchangeRate \u003C ApplicationRecord\n  def self.get_rate(from_iso_code, to_iso_code)\n    rate = find_by(from: from_iso_code, to: to_iso_code)\n    rate&.rate\n  end\n\n  def self.add_rate(from_iso_code, to_iso_code, rate)\n    exrate = find_or_initialize_by(from: from_iso_code, to: to_iso_code)\n    exrate.rate = rate\n    exrate.save!\n  end\n\n  def self.each_rate\n    return find_each unless block_given?\n\n    find_each do |rate|\n      yield rate.from, rate.to, rate.rate\n    end\n  end\n\n  def self.marshal_dump\n    [self]\n  end\nend\n```\n\nThe following example implements a `Redis` store to save exchange rates to a redis database.\n\n```ruby\nclass RedisRateStore\n  INDEX_KEY_SEPARATOR = '_TO_'.freeze\n\n  # Using second db of the redis instance\n  # because sidekiq uses the first db\n  REDIS_DATABASE = 1\n\n  # Using Hash to store rates data\n  REDIS_STORE_KEY = 'rates'\n\n  def initialize\n    conn_url = \"#{Rails.application.credentials.redis_server}\u002F#{REDIS_DATABASE}\"\n    @connection = Redis.new(url: conn_url)\n  end\n\n  def add_rate(iso_from, iso_to, rate)\n    @connection.hset(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to), rate)\n  end\n\n  def get_rate(iso_from, iso_to)\n    @connection.hget(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to))\n  end\n\n  def each_rate\n    rates = @connection.hgetall(REDIS_STORE_KEY)\n    return to_enum(:each_rate) unless block_given?\n\n    rates.each do |key, rate|\n      iso_from, iso_to = key.split(INDEX_KEY_SEPARATOR)\n      yield iso_from, iso_to, rate\n    end\n  end\n\n  def transaction\n    yield\n  end\n\n  private\n\n  def rate_key_for(iso_from, iso_to)\n    [iso_from, iso_to].join(INDEX_KEY_SEPARATOR).upcase\n  end\nend\n```\n\nNow you can use it with the default bank.\n\n```ruby\n# For Rails 6 pass model name as a string to make it compatible with zeitwerk\n# Money.default_bank = Money::Bank::VariableExchange.new(\"ExchangeRate\")\nMoney.default_bank = Money::Bank::VariableExchange.new(ExchangeRate)\n\n# Add to the underlying store\nMoney.default_bank.add_rate('USD', 'CAD', 0.9)\n# Retrieve from the underlying store\nMoney.default_bank.get_rate('USD', 'CAD') # => 0.9\n# Exchanging amounts just works.\nMoney.from_cents(1000, 'USD').exchange_to('CAD') #=> #\u003CMoney fractional:900 currency:CAD>\n```\n\nThere is nothing stopping you from creating store objects which scrapes\n[XE](https:\u002F\u002Fwww.xe.com) for the current rates or just returns `rand(2)`:\n\n```ruby\nMoney.default_bank = Money::Bank::VariableExchange.new(StoreWhichScrapesXeDotCom.new)\n```\n\nYou can also implement your own Bank to calculate exchanges differently.\nDifferent banks can share Stores.\n\n```ruby\nMoney.default_bank = MyCustomBank.new(Money::RatesStore::Memory.new)\n```\n\nIf you wish to disable automatic currency conversion to prevent arithmetic when\ncurrencies don't match:\n\n```ruby\nMoney.disallow_currency_conversion!\n```\n\n### Implementations\n\nThe following is a list of Money.gem compatible currency exchange rate\nimplementations.\n\n- [eu_central_bank](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Feu_central_bank)\n- [google_currency](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fgoogle_currency)\n- [currencylayer](https:\u002F\u002Fgithub.com\u002Faskuratovsky\u002Fcurrencylayer)\n- [nordea](https:\u002F\u002Fgithub.com\u002Fmatiaskorhonen\u002Fnordea)\n- [nbrb_currency](https:\u002F\u002Fgithub.com\u002Fslbug\u002Fnbrb_currency)\n- [money-currencylayer-bank](https:\u002F\u002Fgithub.com\u002Fphlegx\u002Fmoney-currencylayer-bank)\n- [money-open-exchange-rates](https:\u002F\u002Fgithub.com\u002Fspk\u002Fmoney-open-exchange-rates)\n- [money-historical-bank](https:\u002F\u002Fgithub.com\u002Fatwam\u002Fmoney-historical-bank)\n- [russian_central_bank](https:\u002F\u002Fgithub.com\u002Frmustafin\u002Frussian_central_bank)\n- [money-uphold-bank](https:\u002F\u002Fgithub.com\u002Fsubvisual\u002Fmoney-uphold-bank)\n\n## Formatting\n\nThere are several formatting rules for when `Money#format` is called. For more information, check out the [formatting module source](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Fblob\u002Fmain\u002Flib\u002Fmoney\u002Fmoney\u002Fformatter.rb), or read the latest release's [rdoc version](https:\u002F\u002Fwww.rubydoc.info\u002Fgems\u002Fmoney\u002FMoney\u002FFormatter).\n\nIf you wish to format money according to the EU's [Rules for expressing monetary units](https:\u002F\u002Fstyle-guide.europa.eu\u002Fen\u002Fcontent\u002F-\u002Fisg\u002Ftopic?identifier=7.3.3-rules-for-expressing-monetary-units#id370303__id370303_PositionISO) in either English, Irish, Latvian or Maltese:\n\n```ruby\nm = Money.from_cents('123', :gbp) # => #\u003CMoney fractional:123 currency:GBP>\nm.format(symbol: m.currency.to_s + ' ') # => \"GBP 1.23\"\n```\n\nIf you would like to customize currency symbols to avoid ambiguity between currencies, you can:\n\n```ruby\nMoney::Currency.table[:hkd][:symbol] = 'HK$'\n```\n\n## Rounding\n\nBy default, `Money` objects are rounded to the nearest cent and the additional precision is not preserved:\n\n```ruby\nMoney.from_amount(2.34567).format #=> \"$2.35\"\n```\n\nTo retain the additional precision, you will also need to set `infinite_precision` to `true`.\n\n```ruby\nMoney.default_infinite_precision = true\nMoney.from_amount(2.34567).format #=> \"$2.34567\"\n```\n\nTo round to the nearest cent (or anything more precise), you can use the `round` method. However, note that the `round` method on a `Money` object does not work the same way as a normal Ruby `Float` object. Money's `round` method accepts different arguments. The first argument to the round method is the rounding mode, while the second argument is the level of precision relative to the cent.\n\n```ruby\n# Float\n2.34567.round     #=> 2\n2.34567.round(2)  #=> 2.35\n\n# Money\nMoney.default_infinite_precision = true\nMoney.from_cents(2.34567).format #=> \"$0.0234567\"\nMoney.from_cents(2.34567).round.format #=> \"$0.02\"\nMoney.from_cents(2.34567).round(BigDecimal::ROUND_DOWN, 2).format #=> \"$0.0234\"\n```\n\nYou can set the default rounding mode by passing one of the `BigDecimal` mode enumerables like so:\n\n```ruby\nMoney.rounding_mode = BigDecimal::ROUND_HALF_EVEN\n```\n\nSee [BigDecimal::ROUND_MODE](https:\u002F\u002Fruby-doc.org\u002F3.4.1\u002Fgems\u002Fbigdecimal\u002FBigDecimal.html#ROUND_MODE) for more information.\n\nTo round to the nearest cash value in currencies without small denominations:\n\n```ruby\nMoney.from_cents(11_11, \"CHF\").to_nearest_cash_value.format # => \"CHF 11.10\"\n```\n\n## Ruby on Rails\n\nTo integrate money in a Rails application use [money-rails](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney-rails).\n\nFor deprecated methods of integrating with Rails, check [the wiki](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Fwiki).\n\n## Localization\n\nIn order to localize formatting you can use `I18n` gem:\n\n```ruby\nMoney.locale_backend = :i18n\n```\n\nWith this enabled a thousands separator and a decimal mark will get looked up in your `I18n` translation files. In a Rails application this may look like:\n\n```yml\n# config\u002Flocale\u002Fen.yml\nen:\n  number:\n    currency:\n      format:\n        delimiter: \",\"\n        separator: \".\"\n  # falling back to\n  number:\n    format:\n      delimiter: \",\"\n      separator: \".\"\n```\n\nFor this example `Money.from_cents(123456789, \"SEK\").format` will return `1,234,567.89\nkr` which otherwise would have returned `1 234 567,89 kr`.\n\nThis will work seamlessly with [rails-i18n](https:\u002F\u002Fgithub.com\u002Fsvenfuchs\u002Frails-i18n) gem that already has a lot of locales defined.\n\nIf you wish to disable this feature and use defaults instead:\n\n```ruby\nMoney.locale_backend = nil\n```\n\n### Deprecation\n\nThe current default behaviour always checks the I18n locale first, falling back to \"per currency\"\nlocalization. This is now deprecated and will be removed in favour of explicitly defined behaviour\nin the next major release.\n\nIf you would like to use I18n localization (formatting depends on the locale):\n\n```ruby\nMoney.locale_backend = :i18n\n\n# example (using default localization from rails-i18n):\nI18n.locale = :en\nMoney.from_cents(10_000_00, 'USD').format # => $10,000.00\nMoney.from_cents(10_000_00, 'EUR').format # => €10,000.00\n\nI18n.locale = :es\nMoney.from_cents(10_000_00, 'USD').format # => $10.000,00\nMoney.from_cents(10_000_00, 'EUR').format # => €10.000,00\n```\n\nIf you need to localize the position of the currency symbol, you\nhave to pass it manually. *Note: this will become the default formatting\nbehavior in the next version.*\n\n```ruby\nI18n.locale = :fr\nformat = I18n.t :format, scope: 'number.currency.format'\nMoney.from_cents(10_00, 'EUR').format(format: format) # => 10,00 €\n```\n\nFor the legacy behaviour of \"per currency\" localization (formatting depends only on currency):\n\n```ruby\nMoney.locale_backend = :currency\n\n# example:\nMoney.from_cents(10_000_00, 'USD').format # => $10,000.00\nMoney.from_cents(10_000_00, 'EUR').format # => €10.000,00\n```\n\nIn case you don't need localization and would like to use default values (can be redefined using\n`Money.default_formatting_rules`):\n\n```ruby\nMoney.locale_backend = nil\n\n# example:\nMoney.from_cents(10_000_00, 'USD').format # => $10000.00\nMoney.from_cents(10_000_00, 'EUR').format # => €10000.00\n```\n\n## Collection\n\nIn case you're working with collections of `Money` instances, have a look at [money-collection](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney-collection)\nfor improved performance and accuracy.\n\n### Troubleshooting\n\nIf you don't have some locale and don't want to get a runtime error such as:\n\n    I18n::InvalidLocale: :en is not a valid locale\n\nSet the following:\n```ruby\nI18n.enforce_available_locales = false\n```\n\n## Heuristics\n\nPrior to v6.9.0 heuristic analysis of string input was part of this gem. Since then it was extracted in to [money-heuristics gem](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney-heuristics).\n\n## Upgrade Guides\n\nWhen upgrading between major versions, please refer to the appropriate upgrade guide:\n\n- [Upgrading to 7.0](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Fblob\u002Fmain\u002FUPGRADING-7.0.md) - Guide for migrating from 6.x to 7.0\n- [Upgrading to 6.0](https:\u002F\u002Fgithub.com\u002FRubyMoney\u002Fmoney\u002Fblob\u002Fmain\u002FUPGRADING-6.0.md) - Guide for upgrading to version 6.0\n\nThese guides provide detailed information about breaking changes, new features, and step-by-step migration instructions.\n","RubyMoney\u002Fmoney 是一个用于处理货币和货币转换的 Ruby 库。其核心功能包括提供了一个封装了金额及其货币信息的 `Money` 类，以及一个封装了货币单位信息的 `Money::Currency` 类。该库通过将货币值表示为整数（以分为单位）来避免浮点数舍入误差，并支持灵活的货币表示方式。此外，它还提供了货币之间转换的 API。适用于需要精确处理金融交易、电子商务平台或任何涉及多币种计算的应用场景。",2,"2026-06-11 03:15:02","top_language"]