scrooge 0.1.3 → 0.1.4
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.
- data/lib/scrooge.rb +9 -5
- data/scrooge.gemspec +2 -2
- data/spec/scrooge_spec.rb +9 -2
- metadata +2 -2
data/lib/scrooge.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "bigdecimal"
|
2
2
|
|
3
3
|
module Scrooge
|
4
|
-
VERSION = "0.1.
|
4
|
+
VERSION = "0.1.4"
|
5
5
|
|
6
6
|
class Money
|
7
7
|
include Comparable
|
@@ -20,10 +20,14 @@ module Scrooge
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_i
|
23
|
-
|
23
|
+
to_d.to_i
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_f
|
27
|
+
to_d.to_f
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_d
|
27
31
|
BigDecimal(to_cents.to_s) / BigDecimal("100")
|
28
32
|
end
|
29
33
|
|
@@ -68,15 +72,15 @@ module Scrooge
|
|
68
72
|
end
|
69
73
|
|
70
74
|
def method_missing(method, *args, &block)
|
71
|
-
|
75
|
+
to_d.send(method, *args, &block)
|
72
76
|
end
|
73
77
|
|
74
78
|
def respond_to?(method, include_private=false)
|
75
|
-
|
79
|
+
to_d.respond_to?(method, include_private)
|
76
80
|
end
|
77
81
|
|
78
82
|
def to_s
|
79
|
-
sprintf("%.2f",
|
83
|
+
sprintf("%.2f", to_d)
|
80
84
|
end
|
81
85
|
end
|
82
86
|
end
|
data/scrooge.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "scrooge"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.date = "2010-01
|
3
|
+
s.version = "0.1.4"
|
4
|
+
s.date = "2010-02-01"
|
5
5
|
|
6
6
|
s.description = "Class to serialize money into the database, works out of the box with ActiveRecord"
|
7
7
|
s.summary = "Scrooge will keep all your money safe. Or at least in the database."
|
data/spec/scrooge_spec.rb
CHANGED
@@ -6,12 +6,19 @@ include Scrooge
|
|
6
6
|
describe Money do
|
7
7
|
subject { Money.new(175) }
|
8
8
|
|
9
|
-
it "can be interpreted as an
|
9
|
+
it "can be interpreted as an Integer" do
|
10
10
|
subject.to_i.should == 1
|
11
|
+
subject.to_i.class.should == Fixnum
|
11
12
|
end
|
12
13
|
|
13
|
-
it "can be interpreted as a
|
14
|
+
it "can be interpreted as a Float" do
|
14
15
|
subject.to_f.should == 1.75
|
16
|
+
subject.to_f.class.should == Float
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can be interpreted as a BigDecimal" do
|
20
|
+
subject.to_d.should == 1.75
|
21
|
+
subject.to_d.class.should == BigDecimal
|
15
22
|
end
|
16
23
|
|
17
24
|
it "can be zero" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrooge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Nicol\xC3\xA1s Sanguinetti"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01
|
12
|
+
date: 2010-02-01 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|