continued_fractions 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.10 / 2010-03-16
2
+
3
+ * Improved documentation and formatting.
4
+
1
5
  === 0.1.9 / 2010-03-15
2
6
 
3
7
  * Added the lowest term test.
data/README.txt CHANGED
@@ -13,19 +13,26 @@ Generates quotients and convergents for a given number.
13
13
 
14
14
  == Synopsis:
15
15
 
16
- require 'continued_fractions'<br/>
17
- include ContinuedFractions
18
-
19
- frac = Rational(3,2)<br/>
20
- real = Math.log2(frac.to_f)<br/>
21
- cf = ContinuedFraction.new(real,10)<br/>
22
- cf.convergents
23
-
24
- > [(0/1), (1/1), (1/2), (3/5), (7/12), (24/41), (31/53), (179/306), (389/665), (9126/15601)]
25
-
26
- cf.convergent(4)
27
-
28
- > (7/12)
16
+ require 'continued_fractions'
17
+ include ContinuedFractions
18
+
19
+ real = Math::PI
20
+ => 3.14159265358979
21
+
22
+ cf = ContinuedFraction.new(real,10)
23
+ => #<ContinuedFractions::ContinuedFraction:0x00000101101368 @number=3.14159265358979, @limit=10,
24
+ @quotients=[3, 7, 15, 1, 292, 1, 1, 1, 2, 1],
25
+ @convergents=[[0, 1], [1, 0], [3, 1], [22, 7], [333, 106],
26
+ [355, 113], [103993, 33102], [104348, 33215], [208341, 66317], [312689, 99532], [833719, 265381], [1146408, 364913]]>
27
+
28
+ cf.convergents
29
+ => [(3/1), (22/7), (333/106), (355/113), (103993/33102), (104348/33215), (208341/66317), (312689/99532), (833719/265381), (1146408/364913)]
30
+
31
+ cf.convergent(1)
32
+ => (22/7)
33
+
34
+ cf.quotients
35
+ => [3, 7, 15, 1, 292, 1, 1, 1, 2, 1]
29
36
 
30
37
  == Requirements:
31
38
 
@@ -42,23 +49,24 @@ sudo gem install continued_fractions
42
49
 
43
50
  == License:
44
51
 
45
- Copyright (c) 2010 Jose Hales-Garcia
46
-
47
- Permission is hereby granted, free of charge, to any person obtaining
48
- a copy of this software and associated documentation files (the
49
- 'Software'), to deal in the Software without restriction, including
50
- without limitation the rights to use, copy, modify, merge, publish,
51
- distribute, sublicense, and/or sell copies of the Software, and to
52
- permit persons to whom the Software is furnished to do so, subject to
53
- the following conditions:
54
-
55
- The above copyright notice and this permission notice shall be
56
- included in all copies or substantial portions of the Software.
57
-
58
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
59
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
61
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
62
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
63
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
64
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52
+ Copyright (c) 2010 Jose Hales-Garcia
53
+
54
+ Permission is hereby granted, free of charge, to any person obtaining
55
+ a copy of this software and associated documentation files (the
56
+ 'Software'), to deal in the Software without restriction, including
57
+ without limitation the rights to use, copy, modify, merge, publish,
58
+ distribute, sublicense, and/or sell copies of the Software, and to
59
+ permit persons to whom the Software is furnished to do so, subject to
60
+ the following conditions:
61
+
62
+ The above copyright notice and this permission notice shall be
63
+ included in all copies or substantial portions of the Software.
64
+
65
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
66
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
67
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
68
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
69
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
70
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
71
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72
+
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.9') do |config|
5
+ Echoe.new('continued_fractions', '0.1.10') 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,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{continued_fractions}
5
- s.version = "0.1.9"
5
+ s.version = "0.1.10"
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"]
9
- s.date = %q{2010-03-15}
9
+ s.date = %q{2010-03-16}
10
10
  s.description = %q{Generate continued fractions.}
11
11
  s.email = %q{jolohaga@me.com}
12
12
  s.extra_rdoc_files = ["README.txt", "lib/continued_fractions.rb"]
@@ -8,7 +8,7 @@
8
8
  # Copyright:: Copyright (c) 2010 Jose Hales-Garcia
9
9
  #
10
10
  #
11
- module ContinuedFractions #:nodoc:
11
+ module ContinuedFractions
12
12
  class ContinuedFraction
13
13
  attr_accessor :number, :quotients, :limit
14
14
  attr_writer :convergents
@@ -18,6 +18,13 @@ module ContinuedFractions #:nodoc:
18
18
  # The quotients and convergents arrays are length 5, by default. Pass an integer for
19
19
  # the second parameter to change the default.
20
20
  #
21
+ # Example:
22
+ # cf = ContinuedFraction.new(Math::PI,10)
23
+ # => #<ContinuedFractions::ContinuedFraction:0x000001010ed5c8 @number=3.14159265358979, @limit=10,
24
+ # @quotients=[3, 7, 15, 1, 292, 1, 1, 1, 2, 1],
25
+ # @convergents=[[0, 1], [1, 0], [3, 1], [22, 7], [333, 106],
26
+ # [355, 113], [103993, 33102], [104348, 33215], [208341, 66317], [312689, 99532], [833719, 265381], [1146408, 364913]]>
27
+ #
21
28
  def initialize(n,l=5)
22
29
  @number = n
23
30
  @limit = l
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 9
9
- version: 0.1.9
8
+ - 10
9
+ version: 0.1.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Hales-Garcia
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-15 00:00:00 -07:00
17
+ date: 2010-03-16 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency