jruby_big_decimal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/big_decimal.rb +63 -0
  2. metadata +46 -0
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+ require 'java'
3
+
4
+ java_import "java.math.BigDecimal"
5
+
6
+ class BigDecimal
7
+
8
+ def +(y)
9
+ self.add(y)
10
+ end
11
+
12
+ def -(y)
13
+ self.subtract(y)
14
+ end
15
+
16
+ def *(y)
17
+ self.multiply(y)
18
+ end
19
+
20
+ def /(y)
21
+ self.divide(y)
22
+ end
23
+
24
+ def **(n)
25
+ n.class == java.math.BigDecimal ? int_n = n.toString.to_i : int_n = n
26
+ self.pow(int_n)
27
+ end
28
+
29
+ def %(n)
30
+ self.remainder(n).abs
31
+ end
32
+
33
+ def <=(y)
34
+ self.compareTo(y) <= 0
35
+ end
36
+
37
+ def <(y)
38
+ self.compareTo(y) < 0
39
+ end
40
+
41
+ def >=(y)
42
+ self.compareTo(y) >= 0
43
+ end
44
+
45
+ def >(y)
46
+ self.compareTo(y) > 0
47
+ end
48
+
49
+ def ==(y)
50
+ self.equals(y)
51
+ end
52
+
53
+ def !=(y)
54
+ !self.equals(y)
55
+ end
56
+
57
+ def <=>(y)
58
+ return 0 if self == y
59
+ return 1 if self > y
60
+ return -1 if self < y
61
+ end
62
+
63
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_big_decimal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Angelos Kapsimanis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: The gem opens java.math.BigDecimal and overloads the arithmetic operators +, -, *, /, %, **, <=, <. >, >=, <=>, ==, !=
15
+ email: angelos.kapsimanis@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/big_decimal.rb
21
+ homepage: https://github.com/akxs14/jruby_big_decimal
22
+ licenses:
23
+ - MIT
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
+ none: false
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ none: false
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.24
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Operator overloading for JVM's BigDecimal
46
+ test_files: []