traveller 0.0.002 → 0.0.004
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.
- checksums.yaml +4 -4
- data/lib/traveller.rb +10 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38f42af2c3071caebfc5f782169f709cb77afecb
|
4
|
+
data.tar.gz: 4986180bc30893d30d67e526e8f31397e4f9beed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22f1b01b86c8211a9481194c2ccf666b6aab1d1c22c463076ef7f81c09a621832494cb428bee8885bcead55cf9271d60807c8c5598c92c8376b4478eef90e024
|
7
|
+
data.tar.gz: 885811c6d36f219cfe7567864e4fb7a6f1bf14c6222dbda812ef86d8c9d63a872d4b461aad0e3fa6554c3cccc5cbfa345d7d39d60b920864d9e8cf488e75c804
|
data/lib/traveller.rb
CHANGED
@@ -8,9 +8,9 @@ class Traveller
|
|
8
8
|
#
|
9
9
|
# Arguments:
|
10
10
|
# input: (String)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
attr_accessor :city, :state, :latitude, :longitude, :zip, :state_abbreviation
|
13
|
+
|
14
14
|
def initialize(input)
|
15
15
|
@input = input
|
16
16
|
@input.downcase!
|
@@ -33,7 +33,7 @@ class Traveller
|
|
33
33
|
multi_word_states = ['district of columbia', 'new hampshire', 'new jersey', 'new mexico', 'new york', 'north carolina', 'north dakota', 'puerto rico', 'rhode island', 'south carolina', 'south daktoa', 'west virginia' ]
|
34
34
|
abbreviations = ['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'fl', 'ga', 'hi', 'id', 'il', 'in', 'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma', 'mi', 'mn', 'ms', 'mo', 'mt', 'ne', 'nv', 'nh', 'nj', 'nm', 'ny', 'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'pr', 'ri', 'sc', 'sd', 'tn', 'tx', 'ut', 'vt', 'va', 'wa', 'wv', 'wi', 'wy']
|
35
35
|
input_tokens = @input.split
|
36
|
-
|
36
|
+
|
37
37
|
multi_word_states.each { |state|
|
38
38
|
assign_state_and_abbriviation(state) and return if @input.include?(state)
|
39
39
|
}
|
@@ -49,20 +49,18 @@ class Traveller
|
|
49
49
|
|
50
50
|
def assign_state_and_abbriviation(value)
|
51
51
|
state_flashcards = { 'alabama' => 'al', 'alaska' => 'ak', 'america samoa' => 'as', 'arizona' => 'az', 'arkansas' => 'ar', 'california' => 'ca', 'colorado' => 'co', 'connecticut' => 'ct', 'delaware' => 'de', 'district of columbia' => 'dc', 'micronesia1' => 'fm', 'florida' => 'fl', 'georgia' => 'ga', 'guam' => 'gu', 'hawaii' => 'hi', 'idaho' => 'id', 'illinois' => 'il', 'indiana' => 'in', 'iowa' => 'ia', 'kansas' => 'ks', 'kentucky' => 'ky', 'louisiana' => 'la', 'maine' => 'me', 'marshall isands' => 'mh', 'maryland' => 'md', 'massachusetts' => 'ma', 'michigan' => 'mi', 'minnesota' => 'mn', 'mississippi' => 'ms', 'missouri' => 'mo', 'montana' => 'mt', 'nebraska' => 'ne', 'nevada' => 'nv', 'new hampshire' => 'nh', 'new jersey' => 'nj', 'new mexico' => 'nm', 'new york' => 'ny', 'north carolina' => 'nc', 'north dakota' => 'nd', 'ohio' => 'oh', 'oklahoma' => 'ok', 'oregon' => 'or', 'palau' => 'pw', 'pennsylvania' => 'pa', 'puerto rico' => 'pr', 'rhode island' => 'ri', 'south carolina' => 'sc', 'south dakota' => 'sd', 'tennessee' => 'tn', 'texas' => 'tx', 'utah' => 'ut', 'vermont' => 'vt', 'virgin island' => 'vi', 'virginia' => 'va', 'washington' => 'wa', 'west virginia' => 'wv', 'wisconsin' => 'wi', 'wyoming' => 'wy' }
|
52
|
-
@input.sub!(value, '') unless value.nil?
|
53
|
-
|
52
|
+
@input.sub!(value, '') unless value.nil?
|
53
|
+
|
54
54
|
if value.length == 2
|
55
55
|
@state = state_flashcards.invert[value]
|
56
56
|
@state_abbreviation = value
|
57
|
-
else
|
57
|
+
else
|
58
58
|
@state = value
|
59
59
|
@state_abbreviation = state_flashcards[value]
|
60
|
-
end
|
60
|
+
end
|
61
61
|
end
|
62
|
-
|
63
|
-
def parse_city
|
62
|
+
|
63
|
+
def parse_city
|
64
64
|
@city = @input.strip
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
68
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traveller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.004
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Dreger
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: 'Traveller parses location-based strings and exposes their city, state,
|