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.
- checksums.yaml +4 -4
- data/lib/calculator_demo.rb +10 -11
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca680be2dfd9aad5f48619a7743e0ddb9e2ab4797cb5f57ccf39ddac40f1e636
|
|
4
|
+
data.tar.gz: 6df3c08e4f41de947f12d714a541ed1d9e865278f4d66c43cf0579ed957bdaf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba345ff4072bf596c906c4d2c634e99b054cd2e7298a324386b75b286f6f871b2c4d501937d1272db8e24f6e64c1665647e36e9aae361c464d7fdae91e30fd49
|
|
7
|
+
data.tar.gz: 8b396dfdad02e7755cf19fa59f30085df82cb4a7f9370b0f128c5f8255b672d46df466f2166260a9a86229a5106522fdda2875313f7399e7fc9c3153c12e37a6
|
data/lib/calculator_demo.rb
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
module CalculatorDemo
|
|
2
2
|
class Calci
|
|
3
3
|
##perform addition
|
|
4
|
-
def add(
|
|
5
|
-
|
|
4
|
+
def add(*array)
|
|
5
|
+
array.inject(0) { |sum, x| sum += x }
|
|
6
6
|
end
|
|
7
7
|
##perform substraction
|
|
8
|
-
def sub(
|
|
9
|
-
|
|
8
|
+
def sub(*array)
|
|
9
|
+
array.inject { |sum, x| sum -= x }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
##perform multiplication
|
|
13
|
-
def mul(
|
|
14
|
-
|
|
13
|
+
def mul(*array)
|
|
14
|
+
array.inject { |sum, x| sum *= x }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
##perform division
|
|
18
|
-
def div(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def div(*array)
|
|
19
|
+
begin
|
|
20
|
+
array.inject { |sum, x| sum /= x }
|
|
21
21
|
rescue ZeroDivisionError
|
|
22
|
-
"You can't divide
|
|
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.
|
|
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-
|
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: Operations with multiple numbers
|
|
14
14
|
email: hasmukh@thinkbiz.co.in
|
|
15
15
|
executables: []
|
|
16
16
|
extensions: []
|