cash 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/cash.gemspec +1 -1
  2. data/lib/cash.rb +4 -0
  3. data/spec/lib/cash_spec.rb +12 -0
  4. metadata +4 -4
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "cash"
7
- gem.version = '0.2.1'
7
+ gem.version = '0.2.2'
8
8
  gem.authors = ["Norbert Wojtowicz"]
9
9
  gem.email = ["wojtowicz.norbert@gmail.com"]
10
10
  gem.description = "Money model backed by BigDecimal"
@@ -56,6 +56,10 @@ class Cash
56
56
  "%.#{currency.offset}f" % amount.round(currency.offset)
57
57
  end
58
58
 
59
+ def round
60
+ Cash.new(amount.round, currency)
61
+ end
62
+
59
63
  def <=>(o)
60
64
  check_type(o, :compare)
61
65
  amount <=> o.amount
@@ -205,4 +205,16 @@ describe Cash do
205
205
  end
206
206
  end
207
207
 
208
+ describe '#round' do
209
+ it 'rounds to the nearest whole number' do
210
+ Cash.new('1.21', 'USD').round.should == Cash.new('1', 'USD')
211
+ end
212
+
213
+ it 'always returns new object' do
214
+ cash = Cash.new('1', 'PLN')
215
+ cash.round.should eq(cash)
216
+ cash.round.should_not equal(cash)
217
+ end
218
+ end
219
+
208
220
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: 1293552855378689819
82
+ hash: 4258614641162739089
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  segments:
90
90
  - 0
91
- hash: 1293552855378689819
91
+ hash: 4258614641162739089
92
92
  requirements: []
93
93
  rubyforge_project:
94
94
  rubygems_version: 1.8.23