New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

currency_parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency_parser

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

currency_parser

Installation

Add this line to your Rails 3.x application's Gemfile:

gem 'currency_parser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install currency_parser

API Summary

CurrencyParser works in any Ruby class, it does not require Active Record or other ORM. Its default settings has it configured for the German currency format, without allowing negative values.

parser = CurrencyParser::Parser.new
=> #<CurrencyParser::Parser:0x007feca487fe68
 @allow_negative=false,
 @delimiter=".",
 @format=:de,
 @separator=",">

parser.to_us("1,23")
=> "1.23"

parser.to_us("-1,23")
=> "1.23"

The same can be achieved without any change to the default configuration via

CurrencyParser::Parser.to_us("1,23")
=> "1.23"

As of v0.1.2 only the :de format is supported and you can allow negative values as follows

parser = CurrencyParser::Parser.new(:de, :allow_negative => true)
=> #<CurrencyParser::Parser:0x007feca9f999d8
 @allow_negative=true,
 @delimiter=".",
 @format=:de,
 @separator=",">

parser.to_us("-1,23")
=> "-1.23"

Invalid formats will raise an InvalidFormatError exception.

License

This project rocks and uses MIT-LICENSE.

FAQs

Package last updated on 08 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc