Sha256: e5d7dd835ce1d4c13cd8327dd618006f16f19c3fd2d0b1c88158371af67529e3
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 Bytes
Contents
require 'helper' class EnrichmentDb::Census::Datum < EnrichmentDb::DatumModel attr_reader :id DATABASE_NAME = 'censis' def self.by_id(table_name, id) puts "Finding object from #{table_name} with region_id = '#{id}'." query = "SELECT * FROM #{DATABASE_NAME}.#{table_name} where region_id = $1" values = [id] result = EnrichmentDb.request(DATABASE_NAME, query, values) if result.ntuples == 1 puts "Found object with region_id = '#{id}'" format_result(result, id) else puts "Nothing found" nil end end def self.format_result(result, id) result = result[0] 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) region = EnrichmentDb::Helper.hash_float_str_to_float(region) result['region'] = region result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enrichment_db-0.1.5 | lib/enrichment_db/census/datum.rb |