simulator 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/RELEASE.md CHANGED
@@ -1,3 +1,8 @@
1
+ v0.1.3
2
+ ======
3
+ * Added parameter to `Run#step` to allow passing the number of times to
4
+ step
5
+
1
6
  v0.1.2
2
7
  ======
3
8
  * Added detail to gemspec
@@ -23,12 +23,9 @@ module Drop
23
23
  end
24
24
 
25
25
  def model_data
26
- # Run the model 30 steps
27
26
  model_run = @model.new_run
28
- 30.times do
29
- model_run.step
30
- end
31
-
27
+ model_run.step 30
28
+
32
29
  # get the data
33
30
  model_run.data
34
31
  end
@@ -20,26 +20,32 @@ module Mortgage
20
20
  end
21
21
 
22
22
  def model_data
23
+ # a quick convenience method, don't try this at home
24
+ Fixnum.class_eval do
25
+ def years
26
+ self * 12
27
+ end
28
+ end
29
+
23
30
  # fixed rate mortgage
24
31
  fixed = @model.new_run
25
32
  fixed.set payment: 2100
26
- (30 * 12).times { fixed.step }
33
+ fixed.step 30.years
27
34
 
28
35
  # balloon
29
36
  balloon = @model.new_run
30
37
  balloon.set payment: 1850
31
- (30 * 12).times { balloon.step }
38
+ balloon.step 30.years
32
39
 
33
40
  variable = @model.new_run
34
41
  # first 10 years, stick with low payment
35
42
  variable.set payment: 1800
36
- (10 * 12).times do
37
- variable.step
38
- end
43
+ variable.step 10.years
39
44
 
40
45
  # subsequent years, balloon to higher payment until its paid
41
46
  variable.set payment: 2100
42
- (20 * 12).times {variable.step}
47
+ variable.step 20.years
48
+
43
49
  @balances = {
44
50
  variable: variable.data.series(:balance),
45
51
  fixed: fixed.data.series(:balance),
@@ -26,9 +26,11 @@ module Simulator
26
26
  p
27
27
  end
28
28
 
29
- def step
30
- evaluate
31
- increment_period
29
+ def step(times=1)
30
+ times.times do
31
+ evaluate
32
+ increment_period
33
+ end
32
34
  end
33
35
 
34
36
  # The number of periods so far. All runs have at least 1 period.
@@ -1,3 +1,3 @@
1
1
  module Simulator
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simulator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: