calculator_demo 0.1.1 → 0.1.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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/calculator_demo.rb +10 -11
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70aeb7fb0c7433ff7925888a61f92432de9ae8c248b0e0354e10c541d9be9d5e
4
- data.tar.gz: 5cac6ea47818a7898f734468a4ee2645f325431f1b2f4204213d1d185454470c
3
+ metadata.gz: ca680be2dfd9aad5f48619a7743e0ddb9e2ab4797cb5f57ccf39ddac40f1e636
4
+ data.tar.gz: 6df3c08e4f41de947f12d714a541ed1d9e865278f4d66c43cf0579ed957bdaf1
5
5
  SHA512:
6
- metadata.gz: 16fd1488add79b1e60abc2cfe6e80a281689ddae6ab2f675fb731dc71da524db252fb18f55cb27c67ee560f698ff8c7135af8d38ad794e5a5b905305120dca75
7
- data.tar.gz: 4a67bcc23d2d7c1ce6ed0f414951b3c0b3a2a8a18c31007458ef4b4b48e73d5aa29d151c2256f369f2c77e7b9f236b85a19b96015a5069bf6de6d8f463267bce
6
+ metadata.gz: ba345ff4072bf596c906c4d2c634e99b054cd2e7298a324386b75b286f6f871b2c4d501937d1272db8e24f6e64c1665647e36e9aae361c464d7fdae91e30fd49
7
+ data.tar.gz: 8b396dfdad02e7755cf19fa59f30085df82cb4a7f9370b0f128c5f8255b672d46df466f2166260a9a86229a5106522fdda2875313f7399e7fc9c3153c12e37a6
@@ -1,27 +1,26 @@
1
1
  module CalculatorDemo
2
2
  class Calci
3
3
  ##perform addition
4
- def add(a,b)
5
- return a+b
4
+ def add(*array)
5
+ array.inject(0) { |sum, x| sum += x }
6
6
  end
7
7
  ##perform substraction
8
- def sub(a,b)
9
- return a-b
8
+ def sub(*array)
9
+ array.inject { |sum, x| sum -= x }
10
10
  end
11
11
 
12
12
  ##perform multiplication
13
- def mul(a,b)
14
- return a*b
13
+ def mul(*array)
14
+ array.inject { |sum, x| sum *= x }
15
15
  end
16
16
 
17
17
  ##perform division
18
- def div(a,b)
19
- x = begin
20
- a / b
18
+ def div(*array)
19
+ begin
20
+ array.inject { |sum, x| sum /= x }
21
21
  rescue ZeroDivisionError
22
- "You can't divide #{a} by #{b}"
22
+ "You can't divide number with 0"
23
23
  end
24
- return x
25
24
  end
26
25
 
27
26
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calculator_demo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hasmukh Rathod
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Basic functions added.
13
+ description: Operations with multiple numbers
14
14
  email: hasmukh@thinkbiz.co.in
15
15
  executables: []
16
16
  extensions: []