continued_fractions 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,12 @@
1
+ === 0.1.9 / 2010-03-15
2
+
3
+ * Added the lowest term test.
4
+ * Removed begin..end exception block which was hiding failing limit test.
5
+ * Fixed limit test.
6
+
1
7
  === 0.1.8 / 2010-03-15
2
8
 
3
- * Add Rdoc comments.
9
+ * Added Rdoc comments.
4
10
 
5
11
  === 0.1.7 / 2010-03-15
6
12
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('continued_fractions', '0.1.8') do |config|
5
+ Echoe.new('continued_fractions', '0.1.9') do |config|
6
6
  config.summary = 'Generate continued fractions.'
7
7
  config.author = 'Jose Hales-Garcia'
8
8
  config.url = 'http://bitbucket.org/jolohaga/continued_fractions/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{continued_fractions}
5
- s.version = "0.1.8"
5
+ s.version = "0.1.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Hales-Garcia"]
@@ -15,6 +15,9 @@ module ContinuedFractions #:nodoc:
15
15
 
16
16
  # For a given number, n, calculate its continued fraction quotients and convergents.
17
17
  #
18
+ # The quotients and convergents arrays are length 5, by default. Pass an integer for
19
+ # the second parameter to change the default.
20
+ #
18
21
  def initialize(n,l=5)
19
22
  @number = n
20
23
  @limit = l
@@ -23,12 +23,14 @@ module ContinuedFractions
23
23
  end
24
24
 
25
25
  it "should contain convergents approaching the number" do
26
- 0.upto(@cf.convergents.length) do |i|
27
- begin
28
- (@cf.convergents[i+1] - @cf.number).abs <= (@cf.convergents[i] - @cf.number).abs.should == true
29
- rescue
30
- # i+1 has run past the limit of the array.
31
- end
26
+ 0.upto(@cf.convergents.length-2) do |i|
27
+ ((@cf.convergents[i+1] - @cf.number).abs <= (@cf.convergents[i] - @cf.number).abs).should == true
28
+ end
29
+ end
30
+
31
+ it "should contain convergents which are expressed in lowest terms" do
32
+ 1.upto(@cf.convergents.length-1) do |i|
33
+ (@cf.convergent(i-1).numerator*@cf.convergent(i).denominator - @cf.convergent(i).numerator*@cf.convergent(i-1).denominator).should == (-1)**(i)
32
34
  end
33
35
  end
34
36
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Hales-Garcia