ratio 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +7 -0
  3. data/LICENSE +20 -0
  4. data/README.md +4 -0
  5. data/lib/ratio.rb +47 -0
  6. metadata +117 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28fdf7a849485de63bcf4e42f06efbcd565b3438
4
+ data.tar.gz: e723344b702b1f602d939aa26a6424a3d74125ad
5
+ SHA512:
6
+ metadata.gz: c2c9947429c0fac0460ba7cc5fbf176916a74c5252701b25a0c636a67e99f3a0200f8599dba8c4871cf44b57a5bfa51ee925a6f22ace1bd4ea8773731f11025a
7
+ data.tar.gz: 420def2f3659b9334dd3f5dadcf1899f8ecf3eb72c159b21b37fd3dddbba32c0deed1299f691dc3b082365c128cc8c18fd964f43eec3fca16b2cb1f84a45fcfa
@@ -0,0 +1,7 @@
1
+ 1.0.1
2
+
3
+ First actual release :-)
4
+
5
+ 1.0.0 - 2014-02-19
6
+
7
+ First release, yanked
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Matthias Grosser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ ratio
2
+ =====
3
+
4
+ Rationals without the reduction
@@ -0,0 +1,47 @@
1
+ require 'rational'
2
+ require 'forwardable'
3
+
4
+ class Ratio < Numeric
5
+ VERSION = '1.0.1'
6
+
7
+ extend Forwardable
8
+
9
+ def initialize(numerator, denominator)
10
+ raise ZeroDivisionError, 'divided by 0' if 0 == denominator
11
+ @numerator, @denominator = numerator, denominator
12
+ end
13
+
14
+ module InstanceMethods
15
+ def numerator
16
+ @numerator
17
+ end
18
+
19
+ def denominator
20
+ @denominator
21
+ end
22
+
23
+ def to_r
24
+ Rational(numerator, denominator)
25
+ end
26
+
27
+ def to_s
28
+ "#{numerator}:#{denominator}"
29
+ end
30
+
31
+ def inspect
32
+ to_s
33
+ end
34
+ end
35
+
36
+ include InstanceMethods
37
+
38
+ def_instance_delegators :to_r, *(Rational.instance_methods - InstanceMethods.instance_methods - Object.instance_methods + [:==])
39
+ end
40
+
41
+ module Kernel
42
+ private
43
+
44
+ def Ratio(numerator, denominator)
45
+ Ratio.new(numerator, denominator)
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ratio
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthias Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '4.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '4.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.3
83
+ description: Rationals without reduction
84
+ email: mtgrosser@gmx.net
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - lib/ratio.rb
90
+ - LICENSE
91
+ - README.md
92
+ - CHANGELOG
93
+ homepage: http://github.com/mtgrosser/ratio
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.0.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Rationals without reduction
117
+ test_files: []