inflation-calculator 0.0.0

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 (2) hide show
  1. data/lib/inflation-calculator.rb +130 -0
  2. metadata +47 -0
@@ -0,0 +1,130 @@
1
+ require 'bigdecimal'
2
+ require 'bigdecimal/util'
3
+
4
+ class InflationCalc
5
+ #data from the Bureau of Labor Statistics
6
+ def cpi
7
+ cpi = {1913 => 9.9,
8
+ 1914 => 10,
9
+ 1915 => 10.1,
10
+ 1916 => 10.9,
11
+ 1917 => 12.8,
12
+ 1918 => 15.1,
13
+ 1919 => 17.3,
14
+ 1920 => 20,
15
+ 1921 => 17.9,
16
+ 1922 => 16.8,
17
+ 1923 => 17.1,
18
+ 1924 => 17.1,
19
+ 1925 => 17.5,
20
+ 1926 => 17.7,
21
+ 1927 => 17.4,
22
+ 1928 => 17.1,
23
+ 1929 => 17.1,
24
+ 1930 => 16.7,
25
+ 1931 => 15.2,
26
+ 1932 => 13.7,
27
+ 1933 => 13,
28
+ 1934 => 13.4,
29
+ 1935 => 13.7,
30
+ 1936 => 13.9,
31
+ 1937 => 14.4,
32
+ 1938 => 14.1,
33
+ 1939 => 13.9,
34
+ 1940 => 14,
35
+ 1941 => 14.7,
36
+ 1942 => 16.3,
37
+ 1943 => 17.3,
38
+ 1944 => 17.6,
39
+ 1945 => 18,
40
+ 1946 => 19.5,
41
+ 1947 => 22.3,
42
+ 1948 => 24.1,
43
+ 1949 => 23.8,
44
+ 1950 => 24.1,
45
+ 1951 => 26,
46
+ 1952 => 26.5,
47
+ 1953 => 26.7,
48
+ 1954 => 26.9,
49
+ 1955 => 26.8,
50
+ 1956 => 27.2,
51
+ 1957 => 28.1,
52
+ 1958 => 28.9,
53
+ 1959 => 29.1,
54
+ 1960 => 29.6,
55
+ 1961 => 29.9,
56
+ 1962 => 30.2,
57
+ 1963 => 30.6,
58
+ 1964 => 31,
59
+ 1965 => 31.5,
60
+ 1966 => 32.4,
61
+ 1967 => 33.4,
62
+ 1968 => 34.8,
63
+ 1969 => 36.7,
64
+ 1970 => 38.8,
65
+ 1971 => 40.5,
66
+ 1972 => 41.8,
67
+ 1973 => 44.4,
68
+ 1974 => 49.3,
69
+ 1975 => 53.8,
70
+ 1976 => 56.9,
71
+ 1977 => 60.6,
72
+ 1978 => 65.2,
73
+ 1979 => 72.6,
74
+ 1980 => 82.4,
75
+ 1981 => 90.9,
76
+ 1982 => 96.5,
77
+ 1983 => 99.6,
78
+ 1984 => 103.9,
79
+ 1985 => 107.6,
80
+ 1986 => 109.6,
81
+ 1987 => 113.6,
82
+ 1988 => 118.3,
83
+ 1989 => 124,
84
+ 1990 => 130.7,
85
+ 1991 => 136.2,
86
+ 1992 => 140.3,
87
+ 1993 => 144.5,
88
+ 1994 => 148.2,
89
+ 1995 => 152.4,
90
+ 1996 => 156.9,
91
+ 1997 => 160.5,
92
+ 1998 => 163,
93
+ 1999 => 166.6,
94
+ 2000 => 172.2,
95
+ 2001 => 177.1,
96
+ 2002 => 179.9,
97
+ 2003 => 184,
98
+ 2004 => 188.9,
99
+ 2005 => 195.3,
100
+ 2006 => 201.6,
101
+ 2007 => 207.342,
102
+ 2008 => 215.303,
103
+ 2009 => 214.537,
104
+ 2010 => 218.056,
105
+ 2011 => 224.939,
106
+ 2012 => 229.594,
107
+ 2013 => 232.957,
108
+ 2014 => 233.916}
109
+ end
110
+
111
+ def calculate
112
+ print "Enter amount: "
113
+ amount = gets.chomp
114
+ print "Pick a year from 1913 to 2013: "
115
+ year = gets.chomp.to_i
116
+ while true
117
+ if year < 1913 || year > 2013
118
+ print "The year must be from 1913 to 2013. Enter year: "
119
+ year = gets.chomp.to_i
120
+ else
121
+ break
122
+ end
123
+ end
124
+ a = amount.to_d * (cpi[2014].to_d / cpi[year].to_d)
125
+ puts "$#{amount} in #{year} has the same buying power as $#{a.to_f.round(2)} in 2014."
126
+
127
+ end
128
+ end
129
+ f = InflationCalc.new
130
+ f.calculate
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inflation-calculator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Armie Lee
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Enter an amount, pick a year from 1913 to 2013 and learn the equivalent
15
+ buying power in 2014.
16
+ email: armiemargaretlee@yahoo.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/inflation-calculator.rb
22
+ homepage: http://rubygems.org/gems/inflation-calculator
23
+ licenses:
24
+ - MIT
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.28
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Inspired by the Bureau of Labor Statistics' calculator
47
+ test_files: []