continued_fractions 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/continued_fractions.gemspec +2 -2
- data/lib/continued_fractions.rb +5 -6
- data/spec/spec_helper.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 415a29ad4c2573cd6fe71d75bf85da9e9d1b1ae8
|
4
|
+
data.tar.gz: 33669301eb84bfffe3d257d6ab865aa3326a3fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebe93ef1e534aa2e5b79c7c7035617b9781167bd8d0ee88f4e94bb719dc56ad8e0da3d4f50315ac924f4490322eb94f9efcdaf7ce4cf374f3c048f4a3748aba8
|
7
|
+
data.tar.gz: d1fc5b4f88547d95a4572d4365b5dd643dc87f8efe969058bb8fe2e848fdadbde4cc2b8ef54706a847eb026759397fa4a5a10af3326484f2bc23cb3f3aa5ec08
|
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('continued_fractions', '1.5.
|
5
|
+
Echoe.new('continued_fractions', '1.5.1') do |config|
|
6
6
|
config.summary = 'Generate continued fractions'
|
7
7
|
config.description = 'Class for working with continued fractions'
|
8
8
|
|
data/continued_fractions.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: continued_fractions 1.5.
|
2
|
+
# stub: continued_fractions 1.5.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "continued_fractions"
|
6
|
-
s.version = "1.5.
|
6
|
+
s.version = "1.5.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
data/lib/continued_fractions.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
#
|
9
9
|
class ContinuedFraction
|
10
10
|
attr_accessor :number, :quotients, :limit
|
11
|
-
attr_writer :convergents
|
12
11
|
|
13
12
|
# For a given number calculate its continued fraction quotients and convergents up to limit.
|
14
13
|
#
|
@@ -79,25 +78,25 @@ class ContinuedFraction
|
|
79
78
|
|
80
79
|
def +(other)
|
81
80
|
number_of(other) do |num,prec|
|
82
|
-
evaluate("#{
|
81
|
+
evaluate("#{number} + #{num}",prec)
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
85
|
def -(other)
|
87
86
|
number_of(other) do |num,prec|
|
88
|
-
evaluate("#{
|
87
|
+
evaluate("#{number} - #{num}",prec)
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
92
91
|
def /(other)
|
93
92
|
number_of(other) do |num,prec|
|
94
|
-
evaluate("#{
|
93
|
+
evaluate("#{number} / #{num}",prec)
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
97
|
def *(other)
|
99
98
|
number_of(other) do |num,prec|
|
100
|
-
evaluate("#{
|
99
|
+
evaluate("#{number} * #{num}",prec)
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
@@ -126,7 +125,7 @@ class ContinuedFraction
|
|
126
125
|
|
127
126
|
def calculate_quotients #:nodoc:
|
128
127
|
qs = Array.new(limit)
|
129
|
-
n =
|
128
|
+
n = number
|
130
129
|
limit.times do |i|
|
131
130
|
qs[i] = n.to_i
|
132
131
|
n = 1.0/(n-qs[i])
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "/../lib")
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rspec'
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "/../lib")
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rspec'
|
4
4
|
require 'continued_fractions'
|