Sha256: f4b900fb669a5ec02aa9bdcb011973104be3ba10f9ab94288e138570a496d9b9
Contents?: true
Size: 983 Bytes
Versions: 1
Compression:
Stored size: 983 Bytes
Contents
require 'toml' class CSI CURRENT_SIC_YEAR = 2000 # last accurate data set for SIC codes CURRENT_NAICS_YEAR = 2012 # last accurate data set for NAICS codes # Lookup the SIC code. # # Returns a String value of the SIC classification, or nil if not found. def self.lookup_sic(code) lookup_code("sic", CURRENT_SIC_YEAR, code) end # Lookup the NAICS code. # # Returns a String value of the NAICS classification, or nil if not found. def self.lookup_naics(code) lookup_code("naics", CURRENT_NAICS_YEAR, code) end private # Lookup the classification based on the type, year, and code. # # Returns a String value for the resquested classification, or nil if not # found. def self.lookup_code(type, year, code) raise TypeError, 'Integer required' unless code.is_a? Integer begin TOML.load_file("#{File.expand_path(__FILE__+'/..')}/data/#{type}/#{year}/#{code.to_i}.toml")["name"] rescue return nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csi-0.2.0 | lib/csi.rb |