Sha256: 65d52326952a1c7eb5468c536cc24f0cc8828cc6bf861e9309e48bd053702017
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'residence' require 'falls_back_on' class ResidenceRecord < ActiveRecord::Base include Sniff::Emitter include BrighterPlanet::Residence set_table_name 'residential_energy_consumption_survey_responses' def zip_code_name=(value) self.zip_code = ZipCode.find_by_name(value) end def zip_code_name zip_code ? zip_code.name : nil end def rooms return nil unless ROOMS.collect {|t| t.first}.all? { |r| send r.to_s.pluralize.to_sym } ROOMS.map do |room| room_name = room[0] room_options = room[1] send(room_name.to_s.pluralize.to_sym).to_i * room_options[:multiplier] end.sum end def rooms=(room_count) raise ArgumentError, "Can't set rooms directly" unless room_count.nil? update_attributes ROOMS.inject({}) { |memo, r| memo[r[0].to_s.pluralize.to_sym] = nil; memo } end ADJECTIVES = %w( alluring beautiful charming dignified elegant fair graceful handsome inimitable j k lovely magnificent n o pretty q resplendent splendid t unparalleled v well-appointed x y z ) ROOMS = [ [:bedroom, { :max_count => 10, :multiplier => 1 }], [:living_room, { :max_count => 5, :multiplier => 1 }], [:dining_room, { :max_count => 3, :multiplier => 1 }], [:kitchen, { :max_count => 3, :multiplier => 1 }], [:full_bathroom, { :max_count => 10, :multiplier => 0.5 }], [:half_bathroom, { :max_count => 10, :multiplier => 0.25 }], [:heated_garage_berth, { :max_count => 5, :multiplier => 1 }], [:other_room, { :max_count => 10, :multiplier => 1 }] ] end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
residence-0.0.17 | lib/test_support/residence_record.rb |