array_2d 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +83 -11
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/array_2d.gemspec +3 -3
- metadata +10 -10
data/README.rdoc
CHANGED
@@ -1,16 +1,88 @@
|
|
1
1
|
= array_2d
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
==
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
A lightweight mutable 2D array class that allows you to extract and change subarrays. I created it to get around the fact that the ruby core Matrix objects are immutable.
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
gem install array_2d
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
=== Create and modify
|
12
|
+
|
13
|
+
array2d = Array2D.new(2, 3)
|
14
|
+
=> [[nil, nil, nil], [nil, nil, nil]]
|
15
|
+
|
16
|
+
array2d = Array2D.new(2, 3, 0)
|
17
|
+
=> [[0, 0, 0], [0, 0, 0]]
|
18
|
+
|
19
|
+
array2d.state = [[1, 2, 3], [4, 5, 6]]
|
20
|
+
=> [[1, 2, 3], [4, 5, 6]]
|
21
|
+
|
22
|
+
=== Get size
|
23
|
+
|
24
|
+
array2d.size
|
25
|
+
=> [2, 3]
|
26
|
+
|
27
|
+
array2d.row_size
|
28
|
+
=> 2
|
29
|
+
|
30
|
+
array2d.column_size
|
31
|
+
=> 3
|
32
|
+
|
33
|
+
=== Get values
|
34
|
+
|
35
|
+
array2d[0, 2]
|
36
|
+
=> 3
|
37
|
+
|
38
|
+
array2d[1, 0..1]
|
39
|
+
=> [4, 5]
|
40
|
+
|
41
|
+
array2d[0..1, 0..1]
|
42
|
+
=> [[1, 2], [4, 5]]
|
43
|
+
|
44
|
+
# Using two ranges returns another 2d array
|
45
|
+
array2d[0..1, 0..1].class
|
46
|
+
=> Array2D
|
47
|
+
|
48
|
+
=== Set values
|
49
|
+
|
50
|
+
array2d[0, 2] = 11
|
51
|
+
|
52
|
+
array2d
|
53
|
+
=> [[1, 2, 11], [4, 5, 6]]
|
54
|
+
|
55
|
+
# You can set using a single value or a proper size array
|
56
|
+
array2d[1, 0..1] = 9
|
57
|
+
array2d
|
58
|
+
=> [[1, 2, 11], [9, 9, 6]]
|
59
|
+
|
60
|
+
array2d[1, 0..1] = [99, 100]
|
61
|
+
array2d
|
62
|
+
=> [[1, 2, 11], [99, 100, 6]]
|
63
|
+
|
64
|
+
# To set a 2d subarray you must use a single value or another Array2D object
|
65
|
+
array2d[0..1, 0..1] = 44
|
66
|
+
array2d
|
67
|
+
=> [[44, 44, 11], [44, 44, 6]]
|
68
|
+
|
69
|
+
new_subarray = Array2D.new(2, 2)
|
70
|
+
new_subarray.state = [[55, 66], [77, 88]]
|
71
|
+
array2d[0..1, 0..1] = new_subarray
|
72
|
+
array2d
|
73
|
+
=> [[55, 66, 11], [77, 88, 6]]
|
74
|
+
|
75
|
+
=== Enumerate
|
76
|
+
|
77
|
+
# 'Each' goes through the 2d array from left to right, top to bottom
|
78
|
+
array2d.state = [[1, 2, 3], [4, 5, 6]]
|
79
|
+
array2d.each {|e| puts e}
|
80
|
+
1
|
81
|
+
2
|
82
|
+
3
|
83
|
+
4
|
84
|
+
5
|
85
|
+
6
|
14
86
|
|
15
87
|
== Copyright
|
16
88
|
|
data/Rakefile
CHANGED
@@ -16,8 +16,8 @@ Jeweler::Tasks.new do |gem|
|
|
16
16
|
gem.name = "array_2d"
|
17
17
|
gem.homepage = "http://github.com/lukegrecki/array_2d"
|
18
18
|
gem.license = "MIT"
|
19
|
-
gem.summary = "A lightweight
|
20
|
-
gem.description = "
|
19
|
+
gem.summary = "A lightweight mutable 2D array class"
|
20
|
+
gem.description = "Create mutable 2D arrays that allow you to change subarrays."
|
21
21
|
gem.email = "lukegrecki@gmail.com"
|
22
22
|
gem.authors = ["Luke Grecki"]
|
23
23
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/array_2d.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "array_2d"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Luke Grecki"]
|
12
12
|
s.date = "2012-10-08"
|
13
|
-
s.description = "
|
13
|
+
s.description = "Create mutable 2D arrays that allow you to change subarrays."
|
14
14
|
s.email = "lukegrecki@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.licenses = ["MIT"]
|
34
34
|
s.require_paths = ["lib"]
|
35
35
|
s.rubygems_version = "1.8.10"
|
36
|
-
s.summary = "A lightweight
|
36
|
+
s.summary = "A lightweight mutable 2D array class"
|
37
37
|
|
38
38
|
if s.respond_to? :specification_version then
|
39
39
|
s.specification_version = 3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_2d
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-08 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
16
|
-
requirement: &
|
16
|
+
requirement: &87113610 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *87113610
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &87113040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *87113040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &87112770 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,8 +43,8 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
description:
|
46
|
+
version_requirements: *87112770
|
47
|
+
description: Create mutable 2D arrays that allow you to change subarrays.
|
48
48
|
email: lukegrecki@gmail.com
|
49
49
|
executables: []
|
50
50
|
extensions: []
|
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash:
|
81
|
+
hash: 348675471
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
@@ -90,5 +90,5 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 1.8.10
|
91
91
|
signing_key:
|
92
92
|
specification_version: 3
|
93
|
-
summary: A lightweight
|
93
|
+
summary: A lightweight mutable 2D array class
|
94
94
|
test_files: []
|