uscommerce 0.1.0
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/lib/uscommerce.rb +45 -0
- data/lib/uscommerce.rb~ +45 -0
- metadata +48 -0
data/lib/uscommerce.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'queuehash'
|
2
|
+
|
3
|
+
module USCommerce
|
4
|
+
Version = '0.1.0'
|
5
|
+
|
6
|
+
class UsStates
|
7
|
+
# Returns a QueueHash of states, with two-letter postal codes as keys and
|
8
|
+
# state names as values.
|
9
|
+
def self.states
|
10
|
+
QueueHash.new(
|
11
|
+
'AL', 'Alabama', 'AK', 'Alaska', 'AZ', 'Arizona', 'AR', 'Arkansas',
|
12
|
+
'CA', 'California', 'CO', 'Colorado', 'CT', 'Connecticut',
|
13
|
+
'DE', 'Delaware', 'DC', 'District of Columbia', 'FL', 'Florida',
|
14
|
+
'GA', 'Georgia', 'HI', 'Hawaii', 'ID', 'Idaho', 'IL', 'Illinois',
|
15
|
+
'IN', 'Indiana', 'IA', 'Iowa', 'KS', 'Kansas', 'KY', 'Kentucky',
|
16
|
+
'LA', 'Louisiana', 'ME', 'Maine', 'MD', 'Maryland',
|
17
|
+
'MA', 'Massachusetts', 'MI', 'Michigan', 'MN', 'Minnesota',
|
18
|
+
'MS', 'Mississippi', 'MO', 'Missouri', 'MT', 'Montana',
|
19
|
+
'NE', 'Nebraska', 'NV', 'Nevada', 'NH', 'New Hampshire',
|
20
|
+
'NJ', 'New Jersey', 'NM', 'New Mexico', 'NY', 'New York',
|
21
|
+
'NC', 'North Carolina', 'ND', 'North Dakota', 'OH', 'Ohio',
|
22
|
+
'OK', 'Oklahoma', 'OR', 'Oregon', 'PA', 'Pennsylvania',
|
23
|
+
'PR', 'Puerto Rico', 'RI', 'Rhode Island',
|
24
|
+
'SC', 'South Carolina', 'SD', 'South Dakota', 'TN', 'Tennessee',
|
25
|
+
'TX', 'Texas', 'UT', 'Utah', 'VT', 'Vermont', 'VA', 'Virginia',
|
26
|
+
'WA', 'Washington', 'WV', 'West Virginia', 'WI', 'Wisconsin',
|
27
|
+
'WY', 'Wyoming'
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class String
|
34
|
+
# Turns a numeric string into U.S. format if it's not already formatted that
|
35
|
+
# way.
|
36
|
+
#
|
37
|
+
# "10,00".numeric_string_to_us_format -> "10.00"
|
38
|
+
# "10.00".numeric_string_to_us_format -> "10.00"
|
39
|
+
def numeric_string_to_us_format
|
40
|
+
numericString = clone
|
41
|
+
numericString.gsub!(/,/, '.') if numericString =~ /,\d{2}$/
|
42
|
+
numericString
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/lib/uscommerce.rb~
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'queuehash'
|
2
|
+
|
3
|
+
module UsCommerce
|
4
|
+
Version = '0.1.0'
|
5
|
+
|
6
|
+
class UsStates
|
7
|
+
# Returns a QueueHash of states, with two-letter postal codes as keys and
|
8
|
+
# state names as values.
|
9
|
+
def self.states
|
10
|
+
QueueHash.new(
|
11
|
+
'AL', 'Alabama', 'AK', 'Alaska', 'AZ', 'Arizona', 'AR', 'Arkansas',
|
12
|
+
'CA', 'California', 'CO', 'Colorado', 'CT', 'Connecticut',
|
13
|
+
'DE', 'Delaware', 'DC', 'District of Columbia', 'FL', 'Florida',
|
14
|
+
'GA', 'Georgia', 'HI', 'Hawaii', 'ID', 'Idaho', 'IL', 'Illinois',
|
15
|
+
'IN', 'Indiana', 'IA', 'Iowa', 'KS', 'Kansas', 'KY', 'Kentucky',
|
16
|
+
'LA', 'Louisiana', 'ME', 'Maine', 'MD', 'Maryland',
|
17
|
+
'MA', 'Massachusetts', 'MI', 'Michigan', 'MN', 'Minnesota',
|
18
|
+
'MS', 'Mississippi', 'MO', 'Missouri', 'MT', 'Montana',
|
19
|
+
'NE', 'Nebraska', 'NV', 'Nevada', 'NH', 'New Hampshire',
|
20
|
+
'NJ', 'New Jersey', 'NM', 'New Mexico', 'NY', 'New York',
|
21
|
+
'NC', 'North Carolina', 'ND', 'North Dakota', 'OH', 'Ohio',
|
22
|
+
'OK', 'Oklahoma', 'OR', 'Oregon', 'PA', 'Pennsylvania',
|
23
|
+
'PR', 'Puerto Rico', 'RI', 'Rhode Island',
|
24
|
+
'SC', 'South Carolina', 'SD', 'South Dakota', 'TN', 'Tennessee',
|
25
|
+
'TX', 'Texas', 'UT', 'Utah', 'VT', 'Vermont', 'VA', 'Virginia',
|
26
|
+
'WA', 'Washington', 'WV', 'West Virginia', 'WI', 'Wisconsin',
|
27
|
+
'WY', 'Wyoming'
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class String
|
34
|
+
# Turns a numeric string into U.S. format if it's not already formatted that
|
35
|
+
# way.
|
36
|
+
#
|
37
|
+
# "10,00".numeric_string_to_us_format -> "10.00"
|
38
|
+
# "10.00".numeric_string_to_us_format -> "10.00"
|
39
|
+
def numeric_string_to_us_format
|
40
|
+
numericString = clone
|
41
|
+
numericString.gsub!(/,/, '.') if numericString =~ /,\d{2}$/
|
42
|
+
numericString
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.6
|
3
|
+
specification_version: 1
|
4
|
+
name: uscommerce
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2005-06-12
|
8
|
+
summary: UsCommerce contains a few handy methods for handling business functions specific to the United States.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: sera@fhwang.net
|
12
|
+
homepage: http://uscommerce.rubyforge.org/
|
13
|
+
rubyforge_project:
|
14
|
+
description: UsCommerce contains a few handy methods for handling business functions specific to the United States.
|
15
|
+
autorequire: uscommerce
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
authors:
|
28
|
+
- Francis Hwang
|
29
|
+
files:
|
30
|
+
- lib/uscommerce.rb
|
31
|
+
- lib/uscommerce.rb~
|
32
|
+
test_files: []
|
33
|
+
rdoc_options: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
requirements: []
|
38
|
+
dependencies:
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: queuehash
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
43
|
+
requirements:
|
44
|
+
-
|
45
|
+
- ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.0
|
48
|
+
version:
|