Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

picklive-currency

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

picklive-currency

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

picklive-currency

Classes for representing amounts of money or virtual money.

Currently it has GBP and Chips currencies built in.

Examples

# The amount can be given in as the usual value or the integer value:
GBP[5.20] == GBP.new(520) # => true

# They are comparable:
GBP[3.10] > GBP[3.09] # => true
GBP[3.10] > GBP[3.10] # => false

# You can compare with an integer value
GBP[3.10] > 309 # => true

# Equality check is more strict:
GBP[3.10] == 310 # => false

# Objects are instances of Picklive::Currency::Base
GBP[3.10].is_a? Picklive::Currency::Base # => true

GBP[3.10].to_s # => "£3.10"
Chips[100].to_s # => "100 Chips"

Chips[100].class.real? # => false
Chips[100].class.virtual? # => true
GBP[3.10].class.real? # => true

class Transaction
  attr_accessor :amount_in_pennies
  attr_accessor :currency_code
  include Picklive::Currency::ModelMethods
  include Picklive::Currency::Converters
  currency_field :amount
end

t = Transaction.new
t.amount_in_pennies = 310
t.currency_code = 'GBP'

t.amount # => <GBP:3.1>
t.amount_in_currency # => <GBP:3.1>

t.amount = Chips[100]
t.amount_in_pennies # => 100
t.currency_code # => "chips"

FAQs

Package last updated on 14 Feb 2012

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