Sha256: 9efe7ccbb239a3a2fda53792dda9a12fbfcae9974ca57d0227765113727c86b6
Contents?: true
Size: 978 Bytes
Versions: 3
Compression:
Stored size: 978 Bytes
Contents
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}") module EnrichmentDb::Helper def self.float_str_to_float(str) return if str.nil? if str.match(/^[0-9\.-]*$/) str.to_f else str end end def self.hash_float_str_to_float(hash) hash.each_with_object({}) do |(k, v), h| h[k] = float_str_to_float(v) end end def self.format_geo_result(result) if result.size == 1 puts "Found object" result = result.first id = result['region_id'] result = EnrichmentDb::Helper.hash_float_str_to_float(result) region_type = result['region_type'] region_type = region_type[0..-2] region = EnrichmentDb::Geo.const_get(region_type).by_id(id.to_i) return if region.nil? region = EnrichmentDb::Helper.hash_float_str_to_float(region) result['region'] = region result elsif result.size > 1 puts "More than 1 object found. Only wanted 1 object." else puts "Nothing found" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enrichment_db-0.1.15 | lib/enrichment_db/helper.rb |
enrichment_db-0.1.14 | lib/enrichment_db/helper.rb |
enrichment_db-0.1.13 | lib/enrichment_db/helper.rb |