ruby_arithmetic 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.
- checksums.yaml +7 -0
- data/lib/ruby_arithmetic.rb +50 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b019fbbb00af0e13fdc6d7b813de322d69d74967840a5f79c5b557bcf10150f8
|
4
|
+
data.tar.gz: a34f731de5c5122458d0117056387ff1a5e4e1d632fc68761727c83330c37fe5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4059dc475bc207621f3e0641d0a22d2009b473107e5ed4a38d6fa15259c232fab4c1636ed77c65b735771d2ef6491cd757e83acd1e31475b61d8010ae75b2b5a
|
7
|
+
data.tar.gz: caca9ec4c6e910ba2d5524f602a4cb9749a38cb45acb2b0f5e574a74ab9c8438d6a6e566c2b1fa6a1ee547255a66ba546eeabbc3a2a79b397ce6ff752f0fd5f4
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class RubyArithmetic
|
2
|
+
def self.add(n1, n2)
|
3
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
4
|
+
raise "Only integers are allowed"
|
5
|
+
end
|
6
|
+
return (n1 + n2)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.sub(n1, n2)
|
10
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
11
|
+
raise "Only integers are allowed"
|
12
|
+
end
|
13
|
+
return (n1 - n2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.diff(n1, n2)
|
17
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
18
|
+
raise "Only integers are allowed"
|
19
|
+
end
|
20
|
+
return (n1 - n2).abs
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.mul(n1, n2)
|
24
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
25
|
+
raise "Only integers are allowed"
|
26
|
+
end
|
27
|
+
return (n1 * n2)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.div(n1, n2)
|
31
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
32
|
+
raise "Only integers are allowed"
|
33
|
+
end
|
34
|
+
|
35
|
+
if n2 == 0
|
36
|
+
raise "divide by zero error"
|
37
|
+
end
|
38
|
+
return (n1 / n2)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.rem(n1, n2)
|
42
|
+
unless(n1.is_a?(Integer) && n2.is_a?(Integer))
|
43
|
+
raise "Only integers are allowed"
|
44
|
+
end
|
45
|
+
return (n1 % n2)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_arithmetic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aravinthan Chinnasamy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Perform arithmetic operations easily using inbuild function
|
14
|
+
email: caravindhan33@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ruby_arithmetic.rb
|
20
|
+
homepage: https://rubygems.org/gems/ruby_arithmetic
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.1.6
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Arithmetic operations
|
43
|
+
test_files: []
|