paisa 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paisa.rb +4 -4
  3. data/lib/paisa/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaa38290ac4afc7ee38d0ff32429018ab16dadd3
4
- data.tar.gz: f7de502cf23909a04c0fd2f300c6accbf8ece1d2
3
+ metadata.gz: bc752f25537cef88838ce041e8347cfd6e86bae3
4
+ data.tar.gz: 8b538f7c3086861411be83a19880f8e84caa4c11
5
5
  SHA512:
6
- metadata.gz: fb1f3234a4f4aff3a95bbfbfd07625b629c52abc0a9d298d77c9418e9d2889c42f2e71be9b7d016e76b9b4c72634cfb6c16ced191d02c600a77aeaf3dcb5c637
7
- data.tar.gz: 4e078ec975010ba8e03ebb82d942cd786861b06d13bd3b6fae884eac264f1d82aee7bf269ffbe307e3233f6aa6589a2fa52323198b71b23ba7ccbc78abeece32
6
+ metadata.gz: 53e6e6eeae0cbaa5a8528253269c9dbfc31a77d51b6e7df0864c5e80e45e69408e150bfd9de5027a35ef9ec4818bdadd712134e671181b1771f5518790566823
7
+ data.tar.gz: 3007bbe43dab87b1a923627c0a6b17f04ccf1842b7aaf9781218c5461ac4d614634f97af90a0f7082981c920c4915d9e96c97a7fd0956e6f510c740f0746693e
@@ -1,17 +1,17 @@
1
1
  require 'paisa/version'
2
2
 
3
3
  module Paisa
4
- def self.format(paise)
4
+ def self.format(paise, precision: 2)
5
5
  little_endian = paise.to_s.reverse.chars
6
6
  paise = little_endian.shift(2).reverse
7
7
  hundreds = little_endian.shift(3).reverse
8
8
  others = little_endian.each_slice(2).map(&:reverse).map(&:join)
9
9
  rupees = [others.reverse, hundreds.join].flatten.compact.join(',').rjust(1, '0')
10
- [rupees, paise.join.rjust(2, '0')].join('.')
10
+ [rupees, paise.join.rjust(2, '0').slice(0, precision)].reject(&:empty?).join('.')
11
11
  end
12
12
 
13
- def self.format_with_sym(paise)
14
- [symbol, format(paise)].join
13
+ def self.format_with_sym(paise, precision: 2)
14
+ [symbol, format(paise, precision: precision)].join
15
15
  end
16
16
 
17
17
  def self.symbol
@@ -1,3 +1,3 @@
1
1
  module Paisa
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paisa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sudhir Jonathan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-10 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler