Module: Pippa
- Defined in:
- lib/pippa.rb,
lib/pippa/version.rb
Overview
Bundler auto-generated mixin for gem version.
Defined Under Namespace
Classes: Map
Constant Summary collapse
- VERSION =
Current version of Pippa
"0.3.0"
Class Method Summary collapse
-
.compress_zipcodes ⇒ Object
Compress the zipcode CSV file to something that loads quicker.
-
.map_names ⇒ Object
Return a list of the valid map names.
-
.profile ⇒ Object
Run the profiler and record results.
-
.zips ⇒ Object
Return a hash mapping zip codes to CSV records of zip code data.
Class Method Details
.compress_zipcodes ⇒ Object
Compress the zipcode CSV file to something that loads quicker.
This gem is packaged with compressed zipcode table that only works if your ruby has compatible a Marshal
version. If loading fails, it will attempt to rewrite the table in a compatible format, but if you don’t have write permission in the gem store, that will consistently fail. You can use this call with sudo∂ irb to write a compatible table.
28 29 30 |
# File 'lib/pippa.rb', line 28 def self.compress_zipcodes dump_zips.size end |
.map_names ⇒ Object
Return a list of the valid map names.
16 17 18 |
# File 'lib/pippa.rb', line 16 def self.map_names Map.info[:map].keys end |
.profile ⇒ Object
Run the profiler and record results. (For development.)
57 58 59 60 61 62 63 64 65 |
# File 'lib/pippa.rb', line 57 def self.profile require 'ruby-prof' RubyProf.start Map.write_zipcode_maps result = RubyProf.stop File.open('profile.htm', 'w') do |f| RubyProf::GraphHtmlPrinter.new(result).print(f) end end |
.zips ⇒ Object
Return a hash mapping zip codes to CSV records of zip code data. NB: The file is big, so this takes a while to return the first time called.
CSV::Row
struct format (see also ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV/Row.html):
#<CSV::Row
zipcode:"97475"
zip_code_type:"PO BOX"
city:"SPRINGFIELD"
state:"OR"
location_type:"PRIMARY"
lat:44.05
long:-123.02
location:"NA-US-OR-SPRINGFIELD"
decommisioned:"false"
tax_returns_filed:nil
estimated_population:nil
total_wages:nil>
See federalgovernmentzipcodes.us for more information on the zipcode data.
52 53 54 |
# File 'lib/pippa.rb', line 52 def self.zips @@zips ||= zips_from_file end |