cashrb 1.2.1 → 1.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/CHANGELOG.md +6 -0
  2. data/README.md +75 -77
  3. data/cashrb.gemspec +1 -1
  4. metadata +40 -17
@@ -1,3 +1,9 @@
1
+ cashrb v1.2.2
2
+ =============
3
+ - fix formatting in README.md
4
+ - package using 1.8.7 to remove specification date error caused by 1.9 and
5
+ rubygems
6
+
1
7
  cashrb v1.2.1
2
8
  =============
3
9
  - ensure objects created from internal functions such as (+ - * / % divmod)
data/README.md CHANGED
@@ -8,80 +8,78 @@ providing what you need to get your job done.
8
8
  Usage
9
9
  -----
10
10
 
11
- ```ruby
12
- require 'cashrb'
13
-
14
- # Works with cents to avoid Floating point errors
15
- n = Cash.new(100)
16
- n.cents #=> 100
17
- n.to_s #=> "1.00"
18
- n.to_f #=> 1.0
19
-
20
- # Don't like passing cents, set :from => :decimal and use a decimal value
21
- n = Cash.new(1.11, from: :decimal)
22
- n.cents #=> 111
23
- n.to_s #=> "1.11"
24
- n.to_f #=> 1.11
25
-
26
- # Hate cents and always want to pass a decimal, just set the default
27
- Cash.default_from = :decimal
28
- n = Cash.new(1.11)
29
- n.cents #=> 111
30
-
31
- # Define currency as you see fit.
32
- a = Cash.new(100, currency: :usd)
33
- b = Cash.new(100, currency: :eur)
34
- a + b #=> Error! Cash::IncompatibleCurrency
35
-
36
- # Default is 100 cents in a dollar. Is your currency different, then just
37
- # tell it.
38
- n = Cash.new(100, cents_in_dollar: 5)
39
- n.cents #=> 100
40
- n.to_s #=> "20.0"
41
- n.to_f #=> 20.0
42
-
43
- n = Cash.new(100, cents_in_dollar: 10)
44
- n.cents #=> 100
45
- n.to_s #=> "10.0"
46
- n.to_f #=> 10.0
47
-
48
- n = Cash.new(100, cents_in_dollar: 1)
49
- n.cents #=> 100
50
- n.to_s #=> "100"
51
- n.to_f #=> 100.0
52
-
53
- # The default rounding method when dealing with fractional cents is
54
- # BigDecimal::ROUND_HALF_UP. Would you rather use bankers rounding; just
55
- # pass it as an argument.
56
- n = Cash.new(2.5)
57
- n.cents #=> 3
58
-
59
- n = Cash.new(2.5, rounding_method: BigDecimal::ROUND_HALF_EVEN)
60
- n.cents #=> 2
61
-
62
- # Sick of specifying :cents_in_whole, :rounding_method and :currency; just
63
- # set their defaults.
64
- Cash.default_cents_in_whole = 10
65
- Cash.default_rounding_method = BigDecimal::ROUND_DOWN
66
- Cash.default_currency = :EUR
67
-
68
- n = Cash.new(100)
69
- n.to_s #=> "10.0"
70
- n.to_f #=> 10.0
71
- n.currency #=> :EUR
72
-
73
- n = Cash.new(1.9)
74
- n.cents #=> 1
75
-
76
- # If your currency object implements :cents_in_whole, we'll go ahead and
77
- # use that.
78
-
79
- module MyCurrency
80
- def self.cents_in_whole
81
- 10
82
- end
83
- end
84
-
85
- n = Cash.new(9, :currency => MyCurrency)
86
- n.to_f #=> 0.9
87
- ```
11
+ require 'cashrb'
12
+
13
+ # Works with cents to avoid Floating point errors
14
+ n = Cash.new(100)
15
+ n.cents #=> 100
16
+ n.to_s #=> "1.00"
17
+ n.to_f #=> 1.0
18
+
19
+ # Don't like passing cents, set :from => :decimal and use a decimal value
20
+ n = Cash.new(1.11, from: :decimal)
21
+ n.cents #=> 111
22
+ n.to_s #=> "1.11"
23
+ n.to_f #=> 1.11
24
+
25
+ # Hate cents and always want to pass a decimal, just set the default
26
+ Cash.default_from = :decimal
27
+ n = Cash.new(1.11)
28
+ n.cents #=> 111
29
+
30
+ # Define currency as you see fit.
31
+ a = Cash.new(100, currency: :usd)
32
+ b = Cash.new(100, currency: :eur)
33
+ a + b #=> Error! Cash::IncompatibleCurrency
34
+
35
+ # Default is 100 cents in a dollar. Is your currency different, then just
36
+ # tell it.
37
+ n = Cash.new(100, cents_in_dollar: 5)
38
+ n.cents #=> 100
39
+ n.to_s #=> "20.0"
40
+ n.to_f #=> 20.0
41
+
42
+ n = Cash.new(100, cents_in_dollar: 10)
43
+ n.cents #=> 100
44
+ n.to_s #=> "10.0"
45
+ n.to_f #=> 10.0
46
+
47
+ n = Cash.new(100, cents_in_dollar: 1)
48
+ n.cents #=> 100
49
+ n.to_s #=> "100"
50
+ n.to_f #=> 100.0
51
+
52
+ # The default rounding method when dealing with fractional cents is
53
+ # BigDecimal::ROUND_HALF_UP. Would you rather use bankers rounding; just
54
+ # pass it as an argument.
55
+ n = Cash.new(2.5)
56
+ n.cents #=> 3
57
+
58
+ n = Cash.new(2.5, rounding_method: BigDecimal::ROUND_HALF_EVEN)
59
+ n.cents #=> 2
60
+
61
+ # Sick of specifying :cents_in_whole, :rounding_method and :currency; just
62
+ # set their defaults.
63
+ Cash.default_cents_in_whole = 10
64
+ Cash.default_rounding_method = BigDecimal::ROUND_DOWN
65
+ Cash.default_currency = :EUR
66
+
67
+ n = Cash.new(100)
68
+ n.to_s #=> "10.0"
69
+ n.to_f #=> 10.0
70
+ n.currency #=> :EUR
71
+
72
+ n = Cash.new(1.9)
73
+ n.cents #=> 1
74
+
75
+ # If your currency object implements :cents_in_whole, we'll go ahead and
76
+ # use that.
77
+
78
+ module MyCurrency
79
+ def self.cents_in_whole
80
+ 10
81
+ end
82
+ end
83
+
84
+ n = Cash.new(9, :currency => MyCurrency)
85
+ n.to_f #=> 0.9
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cashrb"
3
- s.version = "1.2.1"
3
+ s.version = "1.2.2"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ["Shane Emmons"]
6
6
  s.email = ["semmons99@gmail.com"]
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cashrb
3
- version: !ruby/object:Gem::Version
4
- version: 1.2.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 2
10
+ version: 1.2.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Shane Emmons
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-05-09 00:00:00.000000000Z
17
+
18
+ date: 2011-05-24 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: Lightweight money and currency handler for working with financial calculations.
15
- email:
22
+ email:
16
23
  - semmons99@gmail.com
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - lib/cashrb/cash.rb
22
32
  - lib/cashrb.rb
23
33
  - test/test_cash.rb
@@ -29,23 +39,35 @@ files:
29
39
  - cashrb.gemspec
30
40
  homepage: http://semmons99.github.com/cashrb/
31
41
  licenses: []
42
+
32
43
  post_install_message:
33
44
  rdoc_options: []
34
- require_paths:
45
+
46
+ require_paths:
35
47
  - lib
36
- required_ruby_version: !ruby/object:Gem::Requirement
48
+ required_ruby_version: !ruby/object:Gem::Requirement
37
49
  none: false
38
- requirements:
39
- - - ! '>='
40
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 57
54
+ segments:
55
+ - 1
56
+ - 8
57
+ - 7
41
58
  version: 1.8.7
42
- required_rubygems_version: !ruby/object:Gem::Requirement
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
60
  none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 23
65
+ segments:
66
+ - 1
67
+ - 3
68
+ - 6
47
69
  version: 1.3.6
48
- requirements:
70
+ requirements:
49
71
  - minitest
50
72
  rubyforge_project:
51
73
  rubygems_version: 1.8.1
@@ -53,3 +75,4 @@ signing_key:
53
75
  specification_version: 3
54
76
  summary: Lightweight money and currency handler for working with financial calculations.
55
77
  test_files: []
78
+