radix 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ require 'ae/should'
@@ -0,0 +1 @@
1
+ require 'qed/extensions/check'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radix
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
- - 1
8
- - 1
7
+ - 2
9
8
  - 0
10
- version: 1.1.0
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-03 00:00:00 -04:00
18
+ date: 2010-11-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -55,26 +55,39 @@ extensions: []
55
55
  extra_rdoc_files:
56
56
  - README.rdoc
57
57
  files:
58
+ - doc/01_synopsis.rdoc
59
+ - doc/02_integer.rdoc
60
+ - doc/03_float.rdoc
61
+ - doc/04_rational.rdoc
62
+ - doc/05_base.rdoc
63
+ - doc/applique/ae.rb
64
+ - doc/applique/qed.rb
58
65
  - lib/radix/base.rb
66
+ - lib/radix/float.rb
67
+ - lib/radix/integer.rb
59
68
  - lib/radix/meta/data.rb
60
69
  - lib/radix/meta/package
61
70
  - lib/radix/meta/profile
62
- - lib/radix/number.rb
71
+ - lib/radix/numeric.rb
63
72
  - lib/radix/operator.rb
73
+ - lib/radix/rational.rb
64
74
  - lib/radix.rb
65
75
  - meta/data.rb
66
76
  - meta/package
67
77
  - meta/profile
68
- - qed/applique/ae.rb
69
- - qed/radix_base.rdoc
70
- - qed/radix_operator.rdoc
78
+ - test/02_integer.rdoc
79
+ - test/03_float.rdoc
80
+ - test/04_rational.rdoc
81
+ - test/05_base.rdoc
82
+ - test/applique/ae.rb
83
+ - test/applique/qed.rb
84
+ - HISTORY.rdoc
71
85
  - LICENSE
72
86
  - README.rdoc
73
- - HISTORY
74
87
  has_rdoc: true
75
- homepage: ""
88
+ homepage: http://rubyworks.github.com/radix
76
89
  licenses:
77
- - LGPL
90
+ - Apache 2.0
78
91
  post_install_message:
79
92
  rdoc_options:
80
93
  - --title
@@ -1,84 +0,0 @@
1
- require 'radix/base'
2
-
3
- module Radix
4
-
5
- #
6
- class Number < Numeric
7
-
8
- attr :digits
9
-
10
- attr :base
11
-
12
- def initialize(value, base)
13
- case value
14
- when ::Array
15
- @digits = value
16
- when ::String
17
- @digits = value.to_s.split(//).map{ |e| Radix.convert(e, base, 10).to_i }
18
- when ::Numeric
19
- @digits = value.to_s.split(//).map{ |e| e.to_i }
20
- end
21
- @base = base
22
- end
23
-
24
- def +(other)
25
- operation(:+, other)
26
- end
27
-
28
- def -(other)
29
- operation(:-, other)
30
- end
31
-
32
- def *(other)
33
- operation(:*, other)
34
- end
35
-
36
- def /(other)
37
- operation(:/, other)
38
- end
39
-
40
- def ==(other)
41
- case other
42
- when Radix::Number
43
- if base == other.base
44
- digits == other.digits
45
- else
46
- digits == other.convert(base).digits
47
- end
48
- else
49
-
50
- end
51
- end
52
-
53
- #
54
- def convert(new_base)
55
- new_digits = Radix::Base.convert_base(digits, base, new_base)
56
- self.class.new(new_digits, new_base)
57
- end
58
-
59
- private
60
-
61
- def operation(op, other)
62
- case other
63
- when Radix::Number
64
- s = Radix::Base.convert_base(self.digits , self.base , 10)
65
- o = Radix::Base.convert_base(other.digits, other.base, 10)
66
-
67
- s = s.join.to_i
68
- o = o.join.to_i
69
-
70
- r = s.__send__(op, o)
71
-
72
- r = r.to_s.split(//).map{ |e| e.to_i }
73
-
74
- n = Radix::Base.convert_base(r, 10, self.base)
75
-
76
- Radix::Number.new(n, self.base)
77
- else
78
-
79
- end
80
- end
81
-
82
- end
83
-
84
- end
@@ -1,27 +0,0 @@
1
- = Radix Base Operator
2
-
3
- There first version of Radix worked well enough,
4
- but its API was very functional and thus a bit difficult
5
- to read at a glance.
6
-
7
- To improve upon this Radix now offers an option operater
8
- API.
9
-
10
- require 'radix'
11
-
12
- With it, the #b method extends String and Array classes to
13
- simplify all mulit-base operations.
14
-
15
- r = "1000".b(2) + "2".b(8)
16
- r.assert == "1010".b(2)
17
- r.assert == "12".b(8)
18
- r.assert == "10".b(10)
19
-
20
- r = "AZ42".b(62) + "54".b(10)
21
- r.assert == "8814596".b(10)
22
-
23
- Working with arrays for bases greater than 62.
24
-
25
- r = [100,10].b(256) + "54".b(10)
26
- r.assert == "25664".b(10)
27
-