exonio 0.5.2 → 0.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f03859cf7c728a214f19e108e7a346635c5b419
4
- data.tar.gz: e9d6b0f50cfe6d1b3cc7ba0c9f4c61d5fd438aea
3
+ metadata.gz: 089644ebee28aed7078f0c5ed6c0c28e8ef58e6c
4
+ data.tar.gz: 994f36751c19bb074d6b47fe10fbc4f477321b3f
5
5
  SHA512:
6
- metadata.gz: 69ea29ea9f2f79ff0f37754f3d9f3863f8923c35561911cdfbe909a158e80be56fa7aeb142050bb6da6fe58d6080667dc432512491b196d1258d59115bb74275
7
- data.tar.gz: 52172d1ba501744a5cc5d789f4ecc7f8acb6e2f5ad0a2271c2ec9d3c7f5a82c5b5659553cd5a39652daccc4fdef437b1a827ec43acdb4f31f6790b84637e325d
6
+ metadata.gz: a5c946611830bb1de45b3933f4a7e78e6e8ef253e2e204f3ce0969f6cd5f55d271833f80cf1e71c934c0b37d0b8722f8fabedc4ad511cdfd9b66115586c78048
7
+ data.tar.gz: c1ee25b9476757738c18e4c2e7220edd4b214bf9a803727385284b1a8ae3473c63fce51b3e1e2374d25b26fd6e01721d257639502f1976dc54c061fd9e6c4dbf
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
+ - 2.2
5
+ - 2.1
4
6
  before_install: gem install bundler -v 1.11.2
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.5.3
4
+
5
+ * Fix error on IRR function
6
+
3
7
  ## 0.5.2
4
8
 
5
9
  * Fix the IRR method
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exonio (0.5.2)
4
+ exonio (0.5.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,4 +44,4 @@ DEPENDENCIES
44
44
  rspec (~> 3.0)
45
45
 
46
46
  BUNDLED WITH
47
- 1.11.2
47
+ 1.16.4
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  This gem brings some useful Excel formulas to Ruby. For now, it just has
4
4
  financial formulas, but could have more (like statistical formulas) in the future.
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/exonio.svg)](https://badge.fury.io/rb/exonio)
7
+ [![Build Status](https://travis-ci.org/Noverde/exonio.svg?branch=master)](https://travis-ci.org/Noverde/exonio)
8
+
6
9
  ## Installation
7
10
 
8
11
  Add this line to your application's Gemfile:
@@ -124,6 +127,20 @@ Exonio.rate(12 * 3, 2_500, -50_000) # ==> 0.036006853458478955
124
127
 
125
128
  So, the rate applied is 3.60%.
126
129
 
130
+ ## Statistical formulas
131
+
132
+ ### Sum
133
+ ```ruby
134
+ Exonio.sum([1, 2, 3, 4, 5]) # ==> 15
135
+ ```
136
+ ### Mean
137
+ ```ruby
138
+ Exonio.mean([1, 2, 3, 4, 5]) # ==> 3.0
139
+ ```
140
+ ### Median
141
+ ```ruby
142
+ Exonio.median([1, 2, 3, 6, 5, 4]) # ==> 3.5
143
+ ```
127
144
  ## TODO
128
145
 
129
146
  There's a lot of formulas to be implemented, including:
@@ -158,3 +175,4 @@ Exonio is released under the MIT License.
158
175
  A special thanks goes to the python [NumPy project](http://www.numpy.org/), which was the source for most
159
176
  of the formulas.
160
177
 
178
+
@@ -1,11 +1,14 @@
1
1
  require 'bigdecimal'
2
2
  require 'bigdecimal/newton'
3
+ require "bigdecimal/util"
3
4
 
4
5
  require 'exonio/version'
5
6
  require 'exonio/financial'
6
- require 'exonio/helpers'
7
+ require 'exonio/statistical'
8
+ require 'exonio/helpers/irr_helper'
7
9
 
8
10
  module Exonio
9
11
  extend Newton
10
12
  extend Financial
13
+ extend Statistical
11
14
  end
@@ -21,7 +21,7 @@ module Exonio
21
21
 
22
22
  def values(x)
23
23
  value = Exonio.npv(x[0].to_f, @transactions)
24
- [ value ]
24
+ [ value.to_d ]
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,41 @@
1
+ module Exonio
2
+ module Statistical
3
+
4
+ # Sum of all numbers
5
+ #
6
+ # @param numbers_ary [array] and array of numbers to sum all elements
7
+ #
8
+ # @return [float]
9
+ #
10
+ # @example
11
+ # Exonio.sum([1,2,3,4,5]) # => 15
12
+ def sum(numbers_ary)
13
+ numbers_ary.inject(0, :+)
14
+ end
15
+
16
+ # Simple mean formula: sum elements and / by length
17
+ #
18
+ # @param numbers_ary [array] an array of numbers to calculate the mean
19
+ #
20
+ # @return [float]
21
+ #
22
+ # @example
23
+ # Exonio.mean([1,2,3,4,5]) # => 3.0
24
+ def mean(numbers_ary)
25
+ numbers_ary.inject(0) { |sum, i| sum + i }.to_f / numbers_ary.size
26
+ end
27
+
28
+ # Median formula
29
+ # @param numbers_ary [array] an array of numbers
30
+ #
31
+ # @return [float]
32
+ #
33
+ # @example
34
+ # Exonio.median([1,2,3,4,5]) # => 3.0
35
+ def median(numbers_ary)
36
+ numbers_ary.sort!
37
+ len = numbers_ary.length
38
+ (numbers_ary[(len - 1) / 2] + numbers_ary[len / 2]) / 2.0
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Exonio
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exonio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Izidoro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2018-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,7 +88,8 @@ files:
88
88
  - exonio.gemspec
89
89
  - lib/exonio.rb
90
90
  - lib/exonio/financial.rb
91
- - lib/exonio/helpers.rb
91
+ - lib/exonio/helpers/irr_helper.rb
92
+ - lib/exonio/statistical.rb
92
93
  - lib/exonio/version.rb
93
94
  homepage: http://github.com/noverde/exonio
94
95
  licenses: []