numeric_math 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e89753ee64a6c30a52d65520ed1bd4d6187916d3
4
+ data.tar.gz: 67028435a9179c2de08c2980e20d96d5f94469f9
5
+ SHA512:
6
+ metadata.gz: 8fec71be7a601637bdc5e7efe8c9f8d3226e93950bf79e9a837da69b616be456274e58f0907af49f2f5a5d0d08a9f09c8c12d7ee0a218f139f8ab2bb59743e7f
7
+ data.tar.gz: 41161d42823b43eca4f488dea39960257c5070c7bda0607742e6868fd5012cda5aeebf5e0a63110cf4c91e29db3532da07659996e1a838589573208c8d260898
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Version history
2
+
3
+ [0.0.1] Initial version.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 tero.isannainen@gmail.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,43 @@
1
+ = NumericMath
2
+
3
+ == Overview
4
+
5
+ NumericMath extends the Numeric class with methods from Math
6
+ module. The purpose is to increase productivity when using Math module
7
+ methods interactively. Some might find the simpler approach convenient
8
+ also for actual programs.
9
+
10
+ For example, without NumericMath you take "sin" of 1.5 as:
11
+
12
+ Math.sin( 1.5 )
13
+
14
+ With NumericMath you do:
15
+
16
+ 1.5.sin
17
+
18
+ Math module includes many single argument methods, which take the from
19
+ as above. Two argument methods are mapped, so that first argument is
20
+ "self" and the second argument becomes the first and only parameter
21
+ for the new form.
22
+
23
+ For example, what is originally:
24
+
25
+ Math.log( 4, 2 )
26
+
27
+ is with NumericMath:
28
+
29
+ 4.log( 2 )
30
+
31
+
32
+ The mapped methods are also usable as class methods, e.g:
33
+
34
+ Fixnum.sin( 2 )
35
+
36
+
37
+ == Mapped methods
38
+
39
+ List of single argument methods: cos, sin, tan, acos, asin, atan,
40
+ cosh, sinh, tanh, acosh, asinh, atanh, exp, log2, log10, sqrt, cbrt,
41
+ frexp, erf, erfc, gamma, lgamma.
42
+
43
+ List of two argument methods: atan2, log, hypot, ldexp.
@@ -0,0 +1,47 @@
1
+ # Extend Numeric class with Math module methods.
2
+ class Numeric
3
+
4
+ extend Math
5
+
6
+ # ------------------------------------------------------------
7
+ # Add Math one-arg methods to Numeric.
8
+
9
+ oneArg = [:cos, :sin, :tan, :acos, :asin, :atan, :cosh, :sinh, :tanh,
10
+ :acosh, :asinh, :atanh, :exp, :log2, :log10,
11
+ :sqrt, :cbrt, :frexp, :erf, :erfc, :gamma, :lgamma]
12
+
13
+ oneArg.each do |method|
14
+ define_method( method ) { Numeric.send( method, self ) }
15
+ end
16
+
17
+ public_class_method( *oneArg )
18
+
19
+
20
+ # ------------------------------------------------------------
21
+ # Add Math two-arg methods to Numeric.
22
+
23
+ twoArg = [ :atan2, :log, :hypot, :ldexp ]
24
+
25
+ twoArg.each do |method|
26
+ define_method( method ) { |arg2| Numeric.send( method, self, arg2 ) }
27
+ end
28
+
29
+ public_class_method( *twoArg )
30
+
31
+
32
+ # ------------------------------------------------------------
33
+ # Additional methods:
34
+
35
+ # Convert self to rad.
36
+ def to_rad
37
+ self / 180.0 * Math::PI
38
+ end
39
+
40
+ # Convert self to dec.
41
+ def to_deg
42
+ self * 180.0 / Math::PI
43
+ end
44
+
45
+ end
46
+
47
+ require_relative 'version'
data/lib/version.rb ADDED
@@ -0,0 +1,6 @@
1
+ module Numeric_Math
2
+ VERSION = "0.0.1"
3
+ def Numeric_Math.version
4
+ Numeric_Math::VERSION
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: numeric_math
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tero Isannainen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ NumericMath extends the Numeric class with methods from Math
15
+ module. The purpose is to increase productivity when using Math module
16
+ methods interactively. Some might find the simpler approach convenient
17
+ also for actual programs.
18
+ email: tero.isannainen@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files:
22
+ - README.rdoc
23
+ - CHANGELOG.rdoc
24
+ files:
25
+ - CHANGELOG.rdoc
26
+ - LICENSE
27
+ - README.rdoc
28
+ - lib/numeric_math.rb
29
+ - lib/version.rb
30
+ homepage:
31
+ licenses:
32
+ - Ruby
33
+ metadata: {}
34
+ post_install_message: Check README...
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.9.3
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.5.2
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Add Math module methods as instance methods to Numeric and descendants.
54
+ test_files: []
55
+ has_rdoc: