radix 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +46 -0
- data/.yardopts +5 -0
- data/HISTORY.rdoc +14 -1
- data/NOTICE.rdoc +31 -0
- data/README.rdoc +24 -19
- data/lib/radix.rb +18 -1
- data/lib/radix.yml +46 -0
- data/lib/radix/rational.rb +2 -2
- metadata +52 -92
- data/LICENSE +0 -205
- data/doc/01_synopsis.rdoc +0 -60
- data/doc/02_integer.rdoc +0 -48
- data/doc/03_float.rdoc +0 -36
- data/doc/04_rational.rdoc +0 -27
- data/doc/05_base.rdoc +0 -82
- data/doc/applique/ae.rb +0 -1
- data/doc/applique/qed.rb +0 -1
- data/lib/radix/meta/data.rb +0 -29
- data/lib/radix/meta/package +0 -8
- data/lib/radix/meta/profile +0 -21
- data/meta/data.rb +0 -29
- data/meta/package +0 -8
- data/meta/profile +0 -21
- data/test/02_integer.rdoc +0 -256
- data/test/03_float.rdoc +0 -294
- data/test/04_rational.rdoc +0 -84
- data/test/05_base.rdoc +0 -78
- data/test/applique/ae.rb +0 -1
- data/test/applique/qed.rb +0 -1
data/.ruby
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
source:
|
3
|
+
- meta/
|
4
|
+
authors:
|
5
|
+
- name: Thomas Sawyer
|
6
|
+
email: transfire@gmail.com
|
7
|
+
copyrights:
|
8
|
+
- holder: ''
|
9
|
+
year: '2009'
|
10
|
+
license: BSD-2-Clause
|
11
|
+
replacements: []
|
12
|
+
alternatives: []
|
13
|
+
requirements:
|
14
|
+
- name: detroit
|
15
|
+
groups:
|
16
|
+
- build
|
17
|
+
development: true
|
18
|
+
- name: qed
|
19
|
+
groups:
|
20
|
+
- test
|
21
|
+
development: true
|
22
|
+
dependencies: []
|
23
|
+
conflicts: []
|
24
|
+
repositories:
|
25
|
+
- uri: git://github.com/rubyworks/radix.git
|
26
|
+
scm: git
|
27
|
+
name: upstream
|
28
|
+
resources:
|
29
|
+
home: http://rubyworks.github.com/radix
|
30
|
+
code: http://github.com/rubyworks/radix
|
31
|
+
mail: http://groups.google.com/groups/rubyworks-mailinglist
|
32
|
+
bugs: http://github.com/rubyworks/radix/issues
|
33
|
+
extra: {}
|
34
|
+
load_path:
|
35
|
+
- lib
|
36
|
+
revision: 0
|
37
|
+
created: '2009-07-01'
|
38
|
+
summary: Convert to and from any base.
|
39
|
+
title: Radix
|
40
|
+
version: 2.0.1
|
41
|
+
name: radix
|
42
|
+
description: ! "Radix is a very easy to use Ruby library for converting numbers to
|
43
|
+
and from\nany base. It supports both Integer, Float and Rational numbers, as well
|
44
|
+
as \nrepresentational string-notations that need not be in ASCII order."
|
45
|
+
organization: Rubyworks
|
46
|
+
date: '2011-10-23'
|
data/.yardopts
ADDED
data/HISTORY.rdoc
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
=
|
1
|
+
= RELEASE HISTORY
|
2
|
+
|
3
|
+
== 2.0.1 / 2011-10-23
|
4
|
+
|
5
|
+
This release is simply an adminstrative release to update the project
|
6
|
+
build configuration. The functionality of the library itself has not
|
7
|
+
changed. This release also transitions the project to the BSD-2-Clause
|
8
|
+
license.
|
9
|
+
|
10
|
+
Changes:
|
11
|
+
|
12
|
+
* Modernize build configuration.
|
13
|
+
* Switch to BSD-2-Clause license.
|
14
|
+
|
2
15
|
|
3
16
|
== 2.0.0 / 2010-10-31
|
4
17
|
|
data/NOTICE.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= COPYRIGHT NOTICES
|
2
|
+
|
3
|
+
== Radix
|
4
|
+
|
5
|
+
Copyright:: (c) 2009 Thomas Sawyer, Rubyworks
|
6
|
+
License:: BSD-2-Clause
|
7
|
+
Website:: http://rubyworks.github.com/radix
|
8
|
+
|
9
|
+
Copyright 2011 Thomas Sawyer. All rights reserved.
|
10
|
+
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
13
|
+
|
14
|
+
1. Redistributions of source code must retain the above copyright notice,
|
15
|
+
this list of conditions and the following disclaimer.
|
16
|
+
|
17
|
+
2. Redistributions in binary form must reproduce the above copyright
|
18
|
+
notice, this list of conditions and the following disclaimer in the
|
19
|
+
documentation and/or other materials provided with the distribution.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
25
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
26
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
28
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
29
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
30
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
|
data/README.rdoc
CHANGED
@@ -1,29 +1,33 @@
|
|
1
1
|
= Radix
|
2
2
|
|
3
|
-
|
4
|
-
* code: http://github.com/rubyworks/radix
|
3
|
+
{<img src="http://travis-ci.org/rubyworks/radix.png" />}[http://travis-ci.org/rubyworks/radix]
|
5
4
|
|
5
|
+
License:: BSD-2-Clause
|
6
|
+
Copyright:: 2009 Thomas Sawyer, Rubyworks
|
6
7
|
|
7
|
-
== DESCRIPTION
|
8
8
|
|
9
|
-
|
9
|
+
== DESCRIPTION
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
Radix is a very easy to use Ruby library for converting numbers to and from
|
12
|
+
any base. It supports both Integer, Float and Rational numbers, as well as
|
13
|
+
representational string-notations that need not be in ASCII order.
|
14
14
|
|
15
15
|
|
16
|
-
== FEATURES
|
16
|
+
== FEATURES
|
17
17
|
|
18
18
|
* Convert to and from any base.
|
19
|
-
*
|
20
|
-
*
|
19
|
+
* Convert Integers, Floats and Rational numbers.
|
20
|
+
* Define custom encoding and character sets.
|
21
|
+
* Can be used to encode/decode bytecode strings.
|
21
22
|
* Very intuitive API.
|
22
23
|
|
23
24
|
|
24
|
-
==
|
25
|
+
== RESOURCES
|
25
26
|
|
26
|
-
|
27
|
+
* {Website}[http://rubyworks.github.com/radix]
|
28
|
+
* {Source Code}[http://github.com/rubyworks/radix]
|
29
|
+
* {Mailing List}[http://groups.google/group/rubyworks-mailinglist]
|
30
|
+
* {Issue Tracker}[http://github.com/rubyworks/radix/issues]
|
27
31
|
|
28
32
|
|
29
33
|
== SYNOPSIS
|
@@ -31,6 +35,7 @@ Please see the HISTORY.rdoc file.
|
|
31
35
|
Base conversions with ASCII ordered notations are easy in Ruby.
|
32
36
|
|
33
37
|
255.to_s(16) #=> "FF"
|
38
|
+
|
34
39
|
"FF".to_i(16) #=> 255
|
35
40
|
|
36
41
|
But Ruby reaches it's limit at base 36.
|
@@ -44,12 +49,12 @@ For example, a number in base 256 can be represented by the array [100, 10]
|
|
44
49
|
|
45
50
|
[100,10].b(256).to_a(10) #=> [2,5,6,1,0]
|
46
51
|
|
47
|
-
Or, to get a string representation for any base
|
52
|
+
Or, to get a string representation for any base up to 62.
|
48
53
|
|
49
54
|
[100,10].b(256).to_s(10) #=> "25610"
|
50
55
|
|
51
|
-
A string representation of
|
52
|
-
|
56
|
+
A string representation of a number can be converted too, again,
|
57
|
+
up to base 62.
|
53
58
|
|
54
59
|
"10".b(62).to_s(10) #=> "62"
|
55
60
|
|
@@ -72,10 +77,10 @@ To install with RubyGems simply open a console and type:
|
|
72
77
|
Radix follows {Ruby Setup}[http://rubyworks.github.com/setup] package standard.
|
73
78
|
|
74
79
|
|
75
|
-
==
|
80
|
+
== COPYRIGHTS
|
76
81
|
|
77
|
-
Copyright (c) 2009 Thomas Sawyer
|
82
|
+
Copyright (c) 2009 Thomas Sawyer, Rubyworks
|
78
83
|
|
79
|
-
This program is
|
84
|
+
This program is distributable in accordance with the *FreeBSD* license.
|
80
85
|
|
81
|
-
See
|
86
|
+
See NOTICE.rdoc for details.
|
data/lib/radix.rb
CHANGED
@@ -1,9 +1,26 @@
|
|
1
|
-
require 'radix/meta/data'
|
2
1
|
require 'radix/base'
|
3
2
|
require 'radix/integer'
|
4
3
|
require 'radix/float'
|
5
4
|
require 'radix/rational' # load ?
|
6
5
|
|
6
|
+
module Radix
|
7
|
+
#
|
8
|
+
def self.metadata
|
9
|
+
@metadata ||= (
|
10
|
+
require 'yaml'
|
11
|
+
YAML.load(File.new(File.dirname(__FILE__) + '/radix.yml'))
|
12
|
+
)
|
13
|
+
end
|
14
|
+
#
|
15
|
+
def self.const_missing(name)
|
16
|
+
key = name.to_s.downcase
|
17
|
+
metadata[key] || super(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO: Here only for buggy RUby 1.8.x.
|
21
|
+
VERSION = metadata['version']
|
22
|
+
end
|
23
|
+
|
7
24
|
class ::Float
|
8
25
|
#
|
9
26
|
def b(base)
|
data/lib/radix.yml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
source:
|
3
|
+
- meta/
|
4
|
+
authors:
|
5
|
+
- name: Thomas Sawyer
|
6
|
+
email: transfire@gmail.com
|
7
|
+
copyrights:
|
8
|
+
- holder: ''
|
9
|
+
year: '2009'
|
10
|
+
license: BSD-2-Clause
|
11
|
+
replacements: []
|
12
|
+
alternatives: []
|
13
|
+
requirements:
|
14
|
+
- name: detroit
|
15
|
+
groups:
|
16
|
+
- build
|
17
|
+
development: true
|
18
|
+
- name: qed
|
19
|
+
groups:
|
20
|
+
- test
|
21
|
+
development: true
|
22
|
+
dependencies: []
|
23
|
+
conflicts: []
|
24
|
+
repositories:
|
25
|
+
- uri: git://github.com/rubyworks/radix.git
|
26
|
+
scm: git
|
27
|
+
name: upstream
|
28
|
+
resources:
|
29
|
+
home: http://rubyworks.github.com/radix
|
30
|
+
code: http://github.com/rubyworks/radix
|
31
|
+
mail: http://groups.google.com/groups/rubyworks-mailinglist
|
32
|
+
bugs: http://github.com/rubyworks/radix/issues
|
33
|
+
extra: {}
|
34
|
+
load_path:
|
35
|
+
- lib
|
36
|
+
revision: 0
|
37
|
+
created: '2009-07-01'
|
38
|
+
summary: Convert to and from any base.
|
39
|
+
title: Radix
|
40
|
+
version: 2.0.1
|
41
|
+
name: radix
|
42
|
+
description: ! "Radix is a very easy to use Ruby library for converting numbers to
|
43
|
+
and from\nany base. It supports both Integer, Float and Rational numbers, as well
|
44
|
+
as \nrepresentational string-notations that need not be in ASCII order."
|
45
|
+
organization: Rubyworks
|
46
|
+
date: '2011-10-23'
|
data/lib/radix/rational.rb
CHANGED
@@ -32,11 +32,11 @@ module Radix
|
|
32
32
|
when ::Rational, Rational
|
33
33
|
ratn = numerator
|
34
34
|
base = denominator
|
35
|
-
@value =
|
35
|
+
@value = Rational(ratn.numerator, ratn.denominator)
|
36
36
|
else
|
37
37
|
n = parse_value(numerator, base)
|
38
38
|
d = parse_value(denominator, base)
|
39
|
-
@value =
|
39
|
+
@value = Rational(n, d)
|
40
40
|
end
|
41
41
|
@base, @code = parse_base(base)
|
42
42
|
end
|
metadata
CHANGED
@@ -1,125 +1,85 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: radix
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 2.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Thomas Sawyer
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
name: syckle
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2011-10-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: detroit
|
16
|
+
requirement: &13289720 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: qed
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *13289720
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: qed
|
27
|
+
requirement: &13289040 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
47
33
|
type: :development
|
48
|
-
|
49
|
-
|
50
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *13289040
|
36
|
+
description: ! "Radix is a very easy to use Ruby library for converting numbers to
|
37
|
+
and from\nany base. It supports both Integer, Float and Rational numbers, as well
|
38
|
+
as \nrepresentational string-notations that need not be in ASCII order."
|
39
|
+
email:
|
40
|
+
- transfire@gmail.com
|
51
41
|
executables: []
|
52
|
-
|
53
42
|
extensions: []
|
54
|
-
|
55
|
-
|
43
|
+
extra_rdoc_files:
|
44
|
+
- HISTORY.rdoc
|
56
45
|
- README.rdoc
|
57
|
-
|
58
|
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
- doc/04_rational.rdoc
|
62
|
-
- doc/05_base.rdoc
|
63
|
-
- doc/applique/ae.rb
|
64
|
-
- doc/applique/qed.rb
|
46
|
+
- NOTICE.rdoc
|
47
|
+
files:
|
48
|
+
- .ruby
|
49
|
+
- .yardopts
|
65
50
|
- lib/radix/base.rb
|
66
51
|
- lib/radix/float.rb
|
67
52
|
- lib/radix/integer.rb
|
68
|
-
- lib/radix/meta/data.rb
|
69
|
-
- lib/radix/meta/package
|
70
|
-
- lib/radix/meta/profile
|
71
53
|
- lib/radix/numeric.rb
|
72
54
|
- lib/radix/operator.rb
|
73
55
|
- lib/radix/rational.rb
|
74
56
|
- lib/radix.rb
|
75
|
-
-
|
76
|
-
- meta/package
|
77
|
-
- meta/profile
|
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
|
57
|
+
- lib/radix.yml
|
84
58
|
- HISTORY.rdoc
|
85
|
-
- LICENSE
|
86
59
|
- README.rdoc
|
87
|
-
|
60
|
+
- NOTICE.rdoc
|
88
61
|
homepage: http://rubyworks.github.com/radix
|
89
|
-
licenses:
|
90
|
-
- Apache 2.0
|
62
|
+
licenses: []
|
91
63
|
post_install_message:
|
92
|
-
rdoc_options:
|
93
|
-
|
94
|
-
- Radix API
|
95
|
-
- --main
|
96
|
-
- README.rdoc
|
97
|
-
require_paths:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
98
66
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
68
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
74
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
version: "0"
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
117
79
|
requirements: []
|
118
|
-
|
119
|
-
|
120
|
-
rubygems_version: 1.3.7
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.10
|
121
82
|
signing_key:
|
122
83
|
specification_version: 3
|
123
84
|
summary: Convert to and from any base.
|
124
85
|
test_files: []
|
125
|
-
|