pijush-calculator 0.6.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +83 -0
  4. data/lib/pijush_calculator.rb +60 -0
  5. metadata +50 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb842ad15f15e9cbcf01a2c7bc8ab7ce6177793384f13098ae8e312a2c2e0895
4
+ data.tar.gz: 9c9a0af3577cc92f1d8d4b24071b72b41ce3e9d1a418847f4ed5500c7910a4c1
5
+ SHA512:
6
+ metadata.gz: 12d77661668cab7c1b8483d427e7a6c27b94a54e973c5bd567920b783958c34ea3268e212bb61e6e88019b8969d661e6eab8445731aae00c3d29bcc664fa525e
7
+ data.tar.gz: 6f58d957986e3278b82c4ef97315cf587d14d91f3d1431e45d36ae113001ff29a16fb2343f682a8f64c2712bc400b6e96e5ebe87a37debe7e4e1d7f1f6cb5acc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pijush Chakraborty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # pijush-calculator
2
+
3
+ Advanced, dependency-free Ruby numerical engine for calculator, scientific-math, statistics, and reusable application tooling.
4
+
5
+ ## Engine capabilities
6
+
7
+ - Basic arithmetic: add, subtract, multiply, divide, modulo, power, percentage
8
+ - Utilities: absolute, min/max, average/mean, sum, product, clamp, reciprocal, square, cube
9
+ - Roots: square root and cube root
10
+ - Number theory: factorial, GCD, LCM, combinations, permutations
11
+ - Trigonometry: sine, cosine, tangent, secant, cosecant, cotangent
12
+ - Inverse trigonometry with optional degree output
13
+ - Hyperbolic sine, cosine, tangent
14
+ - Logarithms and exponentials
15
+ - Multi-value hypotenuse calculation
16
+ - Statistics: median, population variance, standard deviation, range
17
+ - Approximate equality helper with configurable tolerance
18
+ - Explicit domain and zero-division validation
19
+ - Ruby 3.0+
20
+ - Zero runtime dependencies
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ gem install pijush-calculator
26
+ ```
27
+
28
+ GitHub Packages:
29
+
30
+ ```bash
31
+ gem install pijush-calculator --source https://rubygems.pkg.github.com/TEJAS-MK2
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```ruby
37
+ require "pijush_calculator"
38
+
39
+ PijushCalculator.add(2, 3) # 5
40
+ PijushCalculator.square_root(144) # 12.0
41
+ PijushCalculator.factorial(6) # 720
42
+ PijushCalculator.median(9, 2, 7, 4, 5) # 5
43
+ PijushCalculator.sine(90, true) # 1.0
44
+ ```
45
+
46
+ ## API
47
+
48
+ | Group | Methods |
49
+ |---|---|
50
+ | Arithmetic | `add`, `subtract`, `multiply`, `divide`, `modulo`, `power`, `percentage` |
51
+ | Utilities | `absolute`, `minimum`, `maximum`, `average`, `mean`, `sum`, `product`, `clamp`, `reciprocal` |
52
+ | Roots | `square_root`, `cube_root`, `square`, `cube` |
53
+ | Number theory | `factorial`, `gcd`, `lcm`, `combinations`, `permutations` |
54
+ | Trigonometry | `sine`, `cosine`, `tangent`, `secant`, `cosecant`, `cotangent` |
55
+ | Inverse trig | `arcsine`, `arccosine`, `arctangent` |
56
+ | Scientific | `logarithm`, `natural_log`, `exponential`, `hypot` |
57
+ | Statistics | `median`, `variance`, `standard_deviation`, `range` |
58
+
59
+ ## Development
60
+
61
+ ```bash
62
+ gem build pijush-calculator.gemspec
63
+ gem test
64
+ ```
65
+
66
+ ## Publishing
67
+
68
+ Releases are handled through GitHub Actions. Published versions are immutable; every release requires a new version. Credentials must never be committed.
69
+
70
+ ## Package information
71
+
72
+ | Property | Value |
73
+ |---|---|
74
+ | Gem | `pijush-calculator` |
75
+ | RubyGems | `https://rubygems.org/gems/pijush-calculator` |
76
+ | GitHub Packages | `https://github.com/TEJAS-MK2/Calculator/packages` |
77
+ | Runtime dependencies | None |
78
+ | Supported Ruby | 3.0+ |
79
+ | License | MIT |
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PijushCalculator
4
+ VERSION = "0.6.0"
5
+ module_function
6
+
7
+ def add(a,b)=a+b
8
+ def subtract(a,b)=a-b
9
+ def multiply(a,b)=a*b
10
+ def divide(a,b);raise ZeroDivisionError,"cannot divide by zero" if b==0;a.to_f/b;end
11
+ def modulo(a,b);raise ZeroDivisionError,"cannot modulo by zero" if b==0;a%b;end
12
+ def power(a,b);raise ZeroDivisionError,"cannot raise zero to a negative power" if a==0&&b.to_f<0;a**b;end
13
+ def percentage(value,percent)=value*percent/100.0
14
+ def absolute(value)=value.abs
15
+ def minimum(*values);raise ArgumentError,"minimum requires a value" if values.empty?;values.min;end
16
+ def maximum(*values);raise ArgumentError,"maximum requires a value" if values.empty?;values.max;end
17
+ def average(*values);raise ArgumentError,"average requires a value" if values.empty?;values.sum.to_f/values.length;end
18
+ def mean(*values)=average(*values)
19
+ def sum(*values)=values.sum
20
+ def product(*values)=values.reduce(1,:*)
21
+ def clamp(value,minimum_value,maximum_value);raise ArgumentError,"minimum cannot exceed maximum" if minimum_value>maximum_value;[[value,minimum_value].max,maximum_value].min;end
22
+ def reciprocal(value);raise ZeroDivisionError,"cannot take reciprocal of zero" if value==0;1.0/value;end
23
+ def square(value)=value*value
24
+ def cube(value)=value*value*value
25
+ def square_root(value);raise ArgumentError,"square root requires a non-negative value" if value<0;Math.sqrt(value);end
26
+ def cube_root(value)=Math.cbrt(value)
27
+ def nth_root(value,degree);raise ArgumentError,"root degree cannot be zero" if degree==0;raise ArgumentError,"even root requires a non-negative value" if value<0&&degree.to_i.even?;value<0 ? -((-value)**(1.0/degree)) : value**(1.0/degree);end
28
+ def factorial(value);n=Integer(value);raise ArgumentError,"factorial requires a non-negative integer" if n<0;(1..n).reduce(1,:*);end
29
+ def gcd(a,b)=a.to_i.gcd(b.to_i)
30
+ def lcm(a,b)=a.to_i.lcm(b.to_i)
31
+ def sine(value,degrees=false)=Math.sin(degrees ? value*Math::PI/180 : value)
32
+ def cosine(value,degrees=false)=Math.cos(degrees ? value*Math::PI/180 : value)
33
+ def tangent(value,degrees=false)=Math.tan(degrees ? value*Math::PI/180 : value)
34
+ def secant(value,degrees=false)=1.0/cosine(value,degrees)
35
+ def cosecant(value,degrees=false)=1.0/sine(value,degrees)
36
+ def cotangent(value,degrees=false)=1.0/tangent(value,degrees)
37
+ def arcsine(value,degrees=false);r=Math.asin(value);degrees ? r*180/Math::PI : r;end
38
+ def arccosine(value,degrees=false);r=Math.acos(value);degrees ? r*180/Math::PI : r;end
39
+ def arctangent(value,degrees=false);r=Math.atan(value);degrees ? r*180/Math::PI : r;end
40
+ def atan2(y,x,degrees=false);r=Math.atan2(y,x);degrees ? r*180/Math::PI : r;end
41
+ def hyperbolic_sine(value)=Math.sinh(value)
42
+ def hyperbolic_cosine(value)=Math.cosh(value)
43
+ def hyperbolic_tangent(value)=Math.tanh(value)
44
+ def logarithm(value,base=10);raise ArgumentError,"invalid logarithm domain" if value<=0||base<=0||base==1;Math.log(value,base);end
45
+ def log2(value);raise ArgumentError,"log2 requires a positive value" if value<=0;Math.log(value,2);end
46
+ def log1p(value);raise ArgumentError,"log1p requires a value greater than -1" if value<=-1;Math.log(1+value);end
47
+ def expm1(value)=Math.exp(value)-1
48
+ def natural_log(value);raise ArgumentError,"natural logarithm requires a positive value" if value<=0;Math.log(value);end
49
+ def exponential(value)=Math.exp(value)
50
+ def hypot(*values);raise ArgumentError,"hypot requires a value" if values.empty?;Math.hypot(*values);end
51
+ def combinations(n,r);n=Integer(n);r=Integer(r);raise ArgumentError,"invalid combination range" if n<0||r<0||r>n;(n-r+1..n).reduce(1,:*)/(1..r).reduce(1,:*).to_f;end
52
+ def permutations(n,r);n=Integer(n);r=Integer(r);raise ArgumentError,"invalid permutation range" if n<0||r<0||r>n;(n-r+1..n).reduce(1,:*);end
53
+ def median(*values);raise ArgumentError,"median requires a value" if values.empty?;s=values.sort;mid=s.length/2;s.length.odd? ? s[mid] : (s[mid-1]+s[mid]).to_f/2;end
54
+ def variance(*values);raise ArgumentError,"variance requires a value" if values.empty?;m=average(*values);values.sum{|v|(v-m)**2}.to_f/values.length;end
55
+ def standard_deviation(*values)=Math.sqrt(variance(*values))
56
+ def range(*values);raise ArgumentError,"range requires a value" if values.empty?;maximum(*values)-minimum(*values);end
57
+ def approximately_equal?(a,b,tolerance=1e-9)=((a-b).abs<=tolerance)
58
+ def finite?(value)=value.respond_to?(:finite?) ? value.finite? : true
59
+ def round_to(value,digits=0);raise ArgumentError,"digits must be an integer" unless digits.is_a?(Integer);value.round(digits);end
60
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pijush-calculator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Pijush Chakraborty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-08-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Dependency-free Ruby arithmetic API for predictable addition, subtraction,
14
+ multiplication, and division with explicit division-by-zero handling.
15
+ email:
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - README.md
22
+ - lib/pijush_calculator.rb
23
+ homepage: https://github.com/TEJAS-MK2/Calculator
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ github_repo: https://github.com/TEJAS-MK2/Calculator
28
+ source_code_uri: https://github.com/TEJAS-MK2/Calculator/tree/main/ruby-gem
29
+ bug_tracker_uri: https://github.com/TEJAS-MK2/Calculator/issues
30
+ changelog_uri: https://github.com/TEJAS-MK2/Calculator/releases
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.5.22
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Lightweight Ruby arithmetic engine for reusable calculator operations.
50
+ test_files: []