rats 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +15 -3
- data/VERSION +1 -1
- data/lib/rats/base.rb +30 -10
- data/lib/rats/data/quarter.rb +20 -2
- data/rats.gemspec +4 -4
- data/spec/rats_spec.rb +19 -0
- metadata +5 -7
data/README.rdoc
CHANGED
@@ -59,14 +59,20 @@ There can be up to a maximum of 36 Sections in a township. The number starts wi
|
|
59
59
|
North of number 6 and counts up West-to-East until the number 12. It snakes back
|
60
60
|
and forth until it finishes at number 36 in the North-East corner.
|
61
61
|
|
62
|
-
===
|
63
|
-
a.k.a.
|
62
|
+
=== Multi
|
63
|
+
a.k.a. Multi Quarters
|
64
64
|
|
65
65
|
from above example: [= N or = North]
|
66
66
|
|
67
67
|
The Half Section represents a 1/2 x 1 mile area within the 1x1 mile Section.
|
68
68
|
They are identified by "N", "E", "S" and "W".
|
69
69
|
|
70
|
+
from above example: [= NSE]
|
71
|
+
|
72
|
+
The Multi Quarter Section represents a 1/2 x 1 mile + 1/2 x 1/2 mile area within the
|
73
|
+
1x1 mile Section (or basically 3 of the 4 quarters).
|
74
|
+
They are identified by "NSE", "NSW", "ENW", "ESW", "SNE", "SNW", "WNE" and "WSE".
|
75
|
+
|
70
76
|
=== Quarter
|
71
77
|
a.k.a. Quarter Section
|
72
78
|
|
@@ -103,11 +109,12 @@ the same location.
|
|
103
109
|
|
104
110
|
Townships, Sections and Half Sections can be divided into multiple Quarter Sections.
|
105
111
|
1 Half Section = 2 Quarter Sections
|
112
|
+
1 Multi Quarter Section = 2-3 Quarter Sections
|
106
113
|
1 Section = 4 Quarter Sections
|
107
114
|
1 Township = 144 Quarter Sections
|
108
115
|
|
109
116
|
For example, the Half Section N 1-2-3 W4 has the Quarter Sections NE 1-2-3 W4 and
|
110
|
-
NW 1-2-3 W4.
|
117
|
+
NW 1-2-3 W4.
|
111
118
|
|
112
119
|
=== Display
|
113
120
|
|
@@ -142,6 +149,11 @@ Divide into multiple Quarter Sections
|
|
142
149
|
quarter_sections = half_section.divide
|
143
150
|
# quarter_sections == [Rats.new("NE 1-2-3 W4"), Rats.new("NW 1-2-3 W4")]
|
144
151
|
|
152
|
+
multi_section = Rats.new("NSE 1-2-3 W4")
|
153
|
+
multi_section.is_divisible?
|
154
|
+
quarter_sections = multi_section.divide
|
155
|
+
# quarter_sections == [Rats.new("NE 1-2-3 W4"), Rats.new("NW 1-2-3 W4"), Rats.new("SE 1-2-3 W4")]
|
156
|
+
|
145
157
|
= Information
|
146
158
|
|
147
159
|
== links
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/rats/base.rb
CHANGED
@@ -172,20 +172,40 @@ module Rats
|
|
172
172
|
|
173
173
|
def divide_half
|
174
174
|
quarters = []
|
175
|
-
case self.quarter.to_s.downcase
|
175
|
+
locations = case self.quarter.to_s.downcase
|
176
176
|
when 'n'
|
177
|
-
|
178
|
-
quarters << Rats.new(self.meridian, self.range, self.township, self.section, 'NW')
|
177
|
+
['NE','NW']
|
179
178
|
when 's'
|
180
|
-
|
181
|
-
quarters << Rats.new(self.meridian, self.range, self.township, self.section, 'SW')
|
179
|
+
['SE','SW']
|
182
180
|
when 'e'
|
183
|
-
|
184
|
-
quarters << Rats.new(self.meridian, self.range, self.township, self.section, 'SE')
|
181
|
+
['NE','SE']
|
185
182
|
when 'w'
|
186
|
-
|
187
|
-
|
183
|
+
['NW','SW']
|
184
|
+
when 'all'
|
185
|
+
['NE','NW','SE','SW']
|
186
|
+
when 'nse'
|
187
|
+
['NE','NW','SE']
|
188
|
+
when 'nsw'
|
189
|
+
['NE','NW','SW']
|
190
|
+
when 'enw'
|
191
|
+
['NE','NW','SE']
|
192
|
+
when 'esw'
|
193
|
+
['NE','SE','SW']
|
194
|
+
when 'sne'
|
195
|
+
['NE','SE','SW']
|
196
|
+
when 'snw'
|
197
|
+
['NW','SE','SW']
|
198
|
+
when 'wse'
|
199
|
+
['NW','SE','SW']
|
200
|
+
when 'wne'
|
201
|
+
['NE','NW','SW']
|
188
202
|
end
|
203
|
+
|
204
|
+
# create the required locations
|
205
|
+
locations.each do |quarter|
|
206
|
+
quarters << Rats.new(self.meridian, self.range, self.township, section || self.section, quarter)
|
207
|
+
end
|
208
|
+
|
189
209
|
quarters
|
190
210
|
end
|
191
211
|
|
@@ -225,7 +245,7 @@ module Rats
|
|
225
245
|
def parse_description(description)
|
226
246
|
# just skip the case of only a meridian ie: 'W4'
|
227
247
|
unless description.to_s.match(/^w\d{1,3}$/i)
|
228
|
-
quarter = description.to_s.scan(/^north|^south|^east|^west|^ne|^nw|^se|^sw|^n|^e|^s|^w/i)
|
248
|
+
quarter = description.to_s.scan(/^north|^south|^east|^west|^all|^nse|^nsw|^enw|^esw|^sne|^snw|^wse|^wne|^ne|^nw|^se|^sw|^n|^e|^s|^w/i)
|
229
249
|
self.quarter = Rats::Quarter.transform(quarter[0]) if quarter && quarter.size > 0
|
230
250
|
end
|
231
251
|
|
data/lib/rats/data/quarter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Rats
|
2
2
|
class Quarter < Data
|
3
3
|
|
4
|
-
VALID_QUARTERS = [:ne, :nw, :se, :sw, :n, :e, :s, :w]
|
4
|
+
VALID_QUARTERS = [:all, :nse, :nsw, :enw, :esw, :sne, :snw, :wse, :wne, :ne, :nw, :se, :sw, :n, :e, :s, :w]
|
5
5
|
|
6
6
|
def self.padding_width; 2; end
|
7
7
|
def self.padding_value; " "; end
|
@@ -30,13 +30,31 @@ module Rats
|
|
30
30
|
sprintf(template, 'South', 'Half')
|
31
31
|
when :w
|
32
32
|
sprintf(template, 'West', 'Half')
|
33
|
+
when :all
|
34
|
+
sprintf(template, 'Entire', 'Section')
|
35
|
+
when :nse
|
36
|
+
sprintf(template, 'North Half and', 'Southeast Quarter')
|
37
|
+
when :nsw
|
38
|
+
sprintf(template, 'North Half and', 'Southwest Quarter')
|
39
|
+
when :enw
|
40
|
+
sprintf(template, 'East Half and', 'Northwest Quarter')
|
41
|
+
when :esw
|
42
|
+
sprintf(template, 'East Half and', 'Southwest Quarter')
|
43
|
+
when :sne
|
44
|
+
sprintf(template, 'South Half and', 'Northeast Quarter')
|
45
|
+
when :snw
|
46
|
+
sprintf(template, 'South Half and', 'Northwest Quarter')
|
47
|
+
when :wse
|
48
|
+
sprintf(template, 'West Half and', 'Southeast Quarter')
|
49
|
+
when :wne
|
50
|
+
sprintf(template, 'West Half and', 'Northeast Quarter')
|
33
51
|
else
|
34
52
|
''
|
35
53
|
end
|
36
54
|
end
|
37
55
|
|
38
56
|
def self.half?(value)
|
39
|
-
%w(north n south s east e west w).include?(value.to_s.downcase)
|
57
|
+
%w(all nse nsw enw esw sne snw wse wne north n south s east e west w).include?(value.to_s.downcase)
|
40
58
|
end
|
41
59
|
|
42
60
|
def self.transform(value)
|
data/rats.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rats}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark G"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-30}
|
13
13
|
s.description = %q{A ruby class to help with using the Alberta Township System}
|
14
14
|
s.email = %q{rats@attackcorp.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.homepage = %q{http://github.com/attack/rats}
|
48
48
|
s.rdoc_options = ["--charset=UTF-8"]
|
49
49
|
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = %q{1.3.
|
50
|
+
s.rubygems_version = %q{1.3.6}
|
51
51
|
s.summary = %q{A ruby class to help with using the Alberta Township System}
|
52
52
|
s.test_files = [
|
53
53
|
"spec/data/data_spec.rb",
|
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
|
|
64
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
65
|
s.specification_version = 3
|
66
66
|
|
67
|
-
if Gem::Version.new(Gem::
|
67
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
68
|
else
|
69
69
|
end
|
70
70
|
else
|
data/spec/rats_spec.rb
CHANGED
@@ -457,6 +457,8 @@ describe "Rats" do
|
|
457
457
|
|
458
458
|
it "is divisible" do
|
459
459
|
Rats.new("N 1-2-3 W4").is_divisible?.should be_true
|
460
|
+
Rats.new("NSE 1-2-3 W4").is_divisible?.should be_true
|
461
|
+
Rats.new("ALL 1-2-3 W4").is_divisible?.should be_true
|
460
462
|
Rats.new("1-2-3 W4").is_divisible?.should be_true
|
461
463
|
Rats.new("2-3 W4").is_divisible?.should be_true
|
462
464
|
end
|
@@ -474,6 +476,14 @@ describe "Rats" do
|
|
474
476
|
quarters.last.quarter.should == 'NW'
|
475
477
|
end
|
476
478
|
|
479
|
+
describe "3/4 -> 3 quarters" do
|
480
|
+
quarters = Rats.new("NSE 1-2-3 W4").divide
|
481
|
+
quarters.size.should == 3
|
482
|
+
quarters[0].quarter.should == 'NE'
|
483
|
+
quarters[1].quarter.should == 'NW'
|
484
|
+
quarters[2].quarter.should == 'SE'
|
485
|
+
end
|
486
|
+
|
477
487
|
describe "section -> 4 quarters" do
|
478
488
|
quarters = Rats.new("1-2-3 W4").divide
|
479
489
|
quarters.size.should == 4
|
@@ -483,6 +493,15 @@ describe "Rats" do
|
|
483
493
|
quarters[3].quarter.should == 'SW'
|
484
494
|
end
|
485
495
|
|
496
|
+
describe "ALL -> 4 quarters" do
|
497
|
+
quarters = Rats.new("ALL 1-2-3 W4").divide
|
498
|
+
quarters.size.should == 4
|
499
|
+
quarters[0].quarter.should == 'NE'
|
500
|
+
quarters[1].quarter.should == 'NW'
|
501
|
+
quarters[2].quarter.should == 'SE'
|
502
|
+
quarters[3].quarter.should == 'SW'
|
503
|
+
end
|
504
|
+
|
486
505
|
describe "township -> 144 quarters" do
|
487
506
|
quarters = Rats.new("2-3 W4").divide
|
488
507
|
quarters.size.should == 144
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mark G
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-30 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -64,7 +64,6 @@ rdoc_options:
|
|
64
64
|
require_paths:
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
67
|
requirements:
|
69
68
|
- - ">="
|
70
69
|
- !ruby/object:Gem::Version
|
@@ -72,7 +71,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
71
|
- 0
|
73
72
|
version: "0"
|
74
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
74
|
requirements:
|
77
75
|
- - ">="
|
78
76
|
- !ruby/object:Gem::Version
|
@@ -82,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
80
|
requirements: []
|
83
81
|
|
84
82
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.6
|
86
84
|
signing_key:
|
87
85
|
specification_version: 3
|
88
86
|
summary: A ruby class to help with using the Alberta Township System
|