bitstring 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS.txt +5 -0
- data/Changelog.txt +20 -0
- data/LICENCE.txt +202 -0
- data/NOTICE.txt +5 -0
- data/README.txt +63 -0
- data/doc/classes/BitString.html +2479 -0
- data/doc/classes/BitString.src/M000001.html +99 -0
- data/doc/classes/BitString.src/M000002.html +18 -0
- data/doc/classes/BitString.src/M000003.html +20 -0
- data/doc/classes/BitString.src/M000004.html +19 -0
- data/doc/classes/BitString.src/M000005.html +24 -0
- data/doc/classes/BitString.src/M000006.html +44 -0
- data/doc/classes/BitString.src/M000007.html +21 -0
- data/doc/classes/BitString.src/M000008.html +18 -0
- data/doc/classes/BitString.src/M000009.html +18 -0
- data/doc/classes/BitString.src/M000010.html +22 -0
- data/doc/classes/BitString.src/M000011.html +29 -0
- data/doc/classes/BitString.src/M000012.html +22 -0
- data/doc/classes/BitString.src/M000013.html +43 -0
- data/doc/classes/BitString.src/M000014.html +19 -0
- data/doc/classes/BitString.src/M000015.html +40 -0
- data/doc/classes/BitString.src/M000016.html +21 -0
- data/doc/classes/BitString.src/M000017.html +18 -0
- data/doc/classes/BitString.src/M000018.html +18 -0
- data/doc/classes/BitString.src/M000019.html +18 -0
- data/doc/classes/BitString.src/M000020.html +20 -0
- data/doc/classes/BitString.src/M000021.html +24 -0
- data/doc/classes/BitString.src/M000022.html +23 -0
- data/doc/classes/BitString.src/M000023.html +42 -0
- data/doc/classes/BitString.src/M000024.html +61 -0
- data/doc/classes/BitString.src/M000025.html +18 -0
- data/doc/classes/BitString.src/M000026.html +18 -0
- data/doc/classes/BitString.src/M000027.html +20 -0
- data/doc/classes/BitString.src/M000028.html +18 -0
- data/doc/classes/BitString.src/M000029.html +18 -0
- data/doc/classes/BitString.src/M000030.html +18 -0
- data/doc/classes/BitString.src/M000031.html +18 -0
- data/doc/classes/BitString.src/M000032.html +18 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/bitstring/operators_rb.html +122 -0
- data/doc/files/lib/bitstring_rb.html +153 -0
- data/doc/fr_class_index.html +27 -0
- data/doc/fr_file_index.html +28 -0
- data/doc/fr_method_index.html +60 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/bitstring.rb +1318 -0
- data/lib/bitstring/operators.rb +481 -0
- data/test/Rakefile +21 -0
- data/test/test_basic.rb +848 -0
- data/test/test_data.rb +24 -0
- data/test/test_enum.rb +671 -0
- data/test/test_helper.rb +3 -0
- data/test/test_operators.rb +454 -0
- metadata +121 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>shrink! (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring.rb, line 852</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shrink!</span>(<span class="ruby-identifier">bits</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">direction</span>=<span class="ruby-constant">HIGH_END</span>)
|
15
|
+
<span class="ruby-identifier">bs</span> = <span class="ruby-identifier">shrink</span>(<span class="ruby-identifier">bits</span>, <span class="ruby-identifier">direction</span>)
|
16
|
+
<span class="ruby-ivar">@length</span> = <span class="ruby-identifier">bs</span>.<span class="ruby-identifier">length</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">bs</span>.<span class="ruby-identifier">bounded?</span>)
|
17
|
+
<span class="ruby-ivar">@value</span> = <span class="ruby-identifier">bs</span>.<span class="ruby-identifier">to_i</span>
|
18
|
+
<span class="ruby-keyword kw">self</span>
|
19
|
+
<span class="ruby-keyword kw">end</span></pre>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>slice (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring.rb, line 879</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args_p</span>)
|
15
|
+
<span class="ruby-keyword kw">self</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">args_p</span>]
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>to_i (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring.rb, line 911</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_i</span>()
|
15
|
+
<span class="ruby-ivar">@value</span>.<span class="ruby-identifier">to_i</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>to_s (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring.rb, line 931</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>()
|
15
|
+
<span class="ruby-identifier">_zfill</span>(<span class="ruby-ivar">@value</span>, <span class="ruby-ivar">@length</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>& (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 76</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">&</span>(<span class="ruby-identifier">val</span>)
|
15
|
+
<span class="ruby-identifier">mask</span> = <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
16
|
+
<span class="ruby-identifier">newval</span> = (<span class="ruby-ivar">@value</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_i</span>) <span class="ruby-operator">&</span> <span class="ruby-identifier">mask</span>
|
17
|
+
<span class="ruby-identifier">bounded?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">newval</span>, <span class="ruby-ivar">@length</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">newval</span>)
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title><< (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 98</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator"><<</span>(<span class="ruby-identifier">bits</span>)
|
15
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-ivar">@value</span> <span class="ruby-operator">*</span> (<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">bits</span>.<span class="ruby-identifier">to_i</span>)
|
16
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">bounded?</span>)
|
17
|
+
<span class="ruby-identifier">mask</span> = <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-ivar">@length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
18
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">mask</span>, <span class="ruby-ivar">@length</span>)
|
19
|
+
<span class="ruby-keyword kw">else</span>
|
20
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>)
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
22
|
+
<span class="ruby-keyword kw">end</span></pre>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>>> (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 124</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">>></span>(<span class="ruby-identifier">bits</span>)
|
15
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-ivar">@value</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">bits</span>.<span class="ruby-identifier">to_i</span>
|
16
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">bounded?</span>)
|
17
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>, <span class="ruby-ivar">@length</span>)
|
18
|
+
<span class="ruby-keyword kw">else</span>
|
19
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>)
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
21
|
+
<span class="ruby-keyword kw">end</span></pre>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>[] (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 155</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">pos_p</span>, <span class="ruby-identifier">length_p</span>=<span class="ruby-keyword kw">nil</span>)
|
15
|
+
<span class="ruby-comment cmt">#</span>
|
16
|
+
<span class="ruby-comment cmt"># Turn a position/length into a range.</span>
|
17
|
+
<span class="ruby-comment cmt">#</span>
|
18
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">pos_p</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">length_p</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>))
|
19
|
+
<span class="ruby-identifier">pos_p</span> = <span class="ruby-constant">Range</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pos_p</span>, <span class="ruby-identifier">pos_p</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">length_p</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
|
20
|
+
<span class="ruby-identifier">length_p</span> = <span class="ruby-keyword kw">nil</span>
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
22
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">pos_p</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Range</span>))
|
23
|
+
<span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">length_p</span>.<span class="ruby-identifier">nil?</span>)
|
24
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'length not allowed with range'</span>)
|
25
|
+
<span class="ruby-keyword kw">end</span>
|
26
|
+
<span class="ruby-identifier">pos_a</span> = <span class="ruby-identifier">pos_p</span>.<span class="ruby-identifier">to_a</span>
|
27
|
+
<span class="ruby-identifier">pos_a</span>.<span class="ruby-identifier">reverse!</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">pos_a</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">pos_a</span>.<span class="ruby-identifier">last</span>)
|
28
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-identifier">pos_a</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">pos</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">pos</span>].<span class="ruby-identifier">to_s</span> }
|
29
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">r</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">''</span>), <span class="ruby-identifier">r</span>.<span class="ruby-identifier">length</span>)
|
30
|
+
<span class="ruby-keyword kw">end</span>
|
31
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">pos_p</span>.<span class="ruby-identifier">to_i</span>
|
32
|
+
<span class="ruby-comment cmt">#</span>
|
33
|
+
<span class="ruby-comment cmt"># Blow an error if we were given an index out of range.</span>
|
34
|
+
<span class="ruby-comment cmt">#</span>
|
35
|
+
<span class="ruby-keyword kw">unless</span> ((<span class="ruby-identifier">pos</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span>) <span class="ruby-operator">&&</span>
|
36
|
+
((<span class="ruby-operator">!</span> <span class="ruby-identifier">bounded?</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">pos</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-value">0</span>, <span class="ruby-ivar">@length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)))
|
37
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">OuttasightIndex</span>, <span class="ruby-identifier">pos</span>)
|
38
|
+
<span class="ruby-keyword kw">end</span>
|
39
|
+
(<span class="ruby-ivar">@value</span> <span class="ruby-operator">&</span> (<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">pos</span>)) <span class="ruby-operator">/</span> (<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">pos</span>)
|
40
|
+
<span class="ruby-keyword kw">end</span></pre>
|
41
|
+
</body>
|
42
|
+
</html>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>[]= (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 204</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args_p</span>)
|
15
|
+
<span class="ruby-identifier">low</span> = <span class="ruby-identifier">high</span> = <span class="ruby-identifier">width</span> = <span class="ruby-keyword kw">nil</span>
|
16
|
+
<span class="ruby-identifier">args</span> = <span class="ruby-identifier">args_p</span>
|
17
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>)
|
18
|
+
<span class="ruby-comment cmt">#</span>
|
19
|
+
<span class="ruby-comment cmt"># [pos]= or [range]=</span>
|
20
|
+
<span class="ruby-comment cmt">#</span>
|
21
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">r</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">class</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-constant">Range</span>))
|
22
|
+
<span class="ruby-comment cmt">#</span>
|
23
|
+
<span class="ruby-comment cmt"># Convert into a [start,length] format to reuse that stream.</span>
|
24
|
+
<span class="ruby-comment cmt">#</span>
|
25
|
+
(<span class="ruby-identifier">start</span>, <span class="ruby-identifier">stop</span>) = [<span class="ruby-identifier">r</span>.<span class="ruby-identifier">first</span>, <span class="ruby-identifier">r</span>.<span class="ruby-identifier">last</span>].<span class="ruby-identifier">sort</span>
|
26
|
+
<span class="ruby-identifier">width</span> = <span class="ruby-identifier">stop</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">start</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
27
|
+
<span class="ruby-identifier">args</span> = [<span class="ruby-identifier">start</span>, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>]]
|
28
|
+
<span class="ruby-keyword kw">else</span>
|
29
|
+
<span class="ruby-identifier">args</span> = [<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>], <span class="ruby-value">1</span>, <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>]]
|
30
|
+
<span class="ruby-keyword kw">end</span>
|
31
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">args_p</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-value">3</span>)
|
32
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">WrongNargs</span>, <span class="ruby-identifier">args_p</span>.<span class="ruby-identifier">length</span>, <span class="ruby-value">3</span>)
|
33
|
+
<span class="ruby-keyword kw">end</span>
|
34
|
+
<span class="ruby-comment cmt">#</span>
|
35
|
+
<span class="ruby-comment cmt"># Special cases of args have now been normalised to [start,length,value].</span>
|
36
|
+
<span class="ruby-comment cmt"># Make sure the values are acceptable.</span>
|
37
|
+
<span class="ruby-comment cmt">#</span>
|
38
|
+
(<span class="ruby-identifier">start</span>, <span class="ruby-identifier">nBits</span>, <span class="ruby-identifier">value</span>) = <span class="ruby-identifier">args</span>
|
39
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">BogoIndex</span>, <span class="ruby-identifier">start</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">start</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_i</span>))
|
40
|
+
<span class="ruby-identifier">start</span> = <span class="ruby-identifier">start</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">start</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>))
|
41
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">BogoIndex</span>, <span class="ruby-identifier">nBits</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">nBits</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_i</span>))
|
42
|
+
<span class="ruby-identifier">nBits</span> = <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">nBits</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>))
|
43
|
+
<span class="ruby-identifier">highpos</span> = <span class="ruby-identifier">start</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">nBits</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
44
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">OuttasightIndex</span>, <span class="ruby-identifier">highpos</span>) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">bounded?</span> <span class="ruby-operator">&&</span> (<span class="ruby-identifier">highpos</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>))
|
45
|
+
<span class="ruby-identifier">_raise</span>(<span class="ruby-constant">BitsRInts</span>, <span class="ruby-identifier">value</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_i</span>))
|
46
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">value</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>))
|
47
|
+
<span class="ruby-comment cmt">#</span>
|
48
|
+
<span class="ruby-comment cmt"># All the checking is done, let's do this thing.</span>
|
49
|
+
<span class="ruby-comment cmt">#</span>
|
50
|
+
<span class="ruby-identifier">mask</span> = <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">nBits</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
51
|
+
<span class="ruby-identifier">value</span> <span class="ruby-operator">&=</span> <span class="ruby-identifier">mask</span>
|
52
|
+
<span class="ruby-identifier">mask</span> <span class="ruby-operator">*=</span> <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">start</span>
|
53
|
+
<span class="ruby-identifier">value</span> <span class="ruby-operator">*=</span> <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">start</span>
|
54
|
+
|
55
|
+
<span class="ruby-identifier">highpos</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span>
|
56
|
+
<span class="ruby-identifier">bValue</span> = <span class="ruby-ivar">@value</span> <span class="ruby-operator">&</span> ((<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">highpos</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&</span> <span class="ruby-operator">~</span><span class="ruby-identifier">mask</span>)
|
57
|
+
<span class="ruby-ivar">@value</span> = <span class="ruby-identifier">bValue</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">value</span>
|
58
|
+
<span class="ruby-identifier">value</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-identifier">start</span>
|
59
|
+
<span class="ruby-keyword kw">end</span></pre>
|
60
|
+
</body>
|
61
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>^ (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 263</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">^</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>| (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 279</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>~ (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 295</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">~</span>()
|
15
|
+
<span class="ruby-identifier">mask</span> = <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
16
|
+
<span class="ruby-identifier">newval</span> = (<span class="ruby-operator">~</span> <span class="ruby-ivar">@value</span>) <span class="ruby-operator">&</span> <span class="ruby-identifier">mask</span>
|
17
|
+
<span class="ruby-identifier">bounded?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">newval</span>, <span class="ruby-ivar">@length</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">newval</span>)
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>== (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 313</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>^ (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 267</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">^</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>| (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 283</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>~ (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 299</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">~</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>== (BitString)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/bitstring/operators.rb, line 315</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">val_p</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">val_p</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
data/doc/created.rid
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thu, 04 Feb 2010 20:19:57 -0500
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: operators.rb</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>operators.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/bitstring/operators.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Thu Feb 04 18:32:44 -0500 2010</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<h1>operators.rb - Operators for the <a href="../../../classes/BitString.html">BitString</a> class</h1>
|
73
|
+
<table>
|
74
|
+
<tr><td valign="top">Author:</td><td>Ken Coar
|
75
|
+
|
76
|
+
</td></tr>
|
77
|
+
<tr><td valign="top">Copyright:</td><td>Copyright © 2010 Ken Coar
|
78
|
+
|
79
|
+
</td></tr>
|
80
|
+
<tr><td valign="top">License:</td><td>Apache Licence 2.0
|
81
|
+
|
82
|
+
</td></tr>
|
83
|
+
</table>
|
84
|
+
<h2>Description</h2>
|
85
|
+
<p>
|
86
|
+
Operator methods for <em><a
|
87
|
+
href="../../../classes/BitString.html">BitString</a></em> class
|
88
|
+
(<em>e.g.</em>, those consisting of special characters).
|
89
|
+
</p>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if includes -->
|
101
|
+
|
102
|
+
<div id="section">
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
<!-- if method_list -->
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
|
117
|
+
<div id="validator-badges">
|
118
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
</body>
|
122
|
+
</html>
|