residence 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,5 +3,26 @@ require 'emitter'
3
3
  module BrighterPlanet
4
4
  module Residence
5
5
  extend BrighterPlanet::Emitter
6
+ ROOMS = [
7
+ [:bedroom, { :max_count => 10, :multiplier => 1 }],
8
+ [:living_room, { :max_count => 5, :multiplier => 1 }],
9
+ [:dining_room, { :max_count => 3, :multiplier => 1 }],
10
+ [:kitchen, { :max_count => 3, :multiplier => 1 }],
11
+ [:full_bathroom, { :max_count => 10, :multiplier => 0.5 }],
12
+ [:half_bathroom, { :max_count => 10, :multiplier => 0.25 }],
13
+ [:heated_garage_berth, { :max_count => 5, :multiplier => 1 }],
14
+ [:other_room, { :max_count => 10, :multiplier => 1 }]
15
+ ]
16
+ def zip_code_name
17
+ zip_code ? zip_code.name : nil
18
+ end
19
+ def rooms
20
+ return nil unless ROOMS.collect {|t| t.first}.all? { |r| send r.to_s.pluralize.to_sym }
21
+ ROOMS.map do |room|
22
+ room_name = room[0]
23
+ room_options = room[1]
24
+ send(room_name.to_s.pluralize.to_sym).to_i * room_options[:multiplier]
25
+ end.sum
26
+ end
6
27
  end
7
28
  end
@@ -4,67 +4,11 @@ require 'falls_back_on'
4
4
  class ResidenceRecord < ActiveRecord::Base
5
5
  include Sniff::Emitter
6
6
  include BrighterPlanet::Residence
7
- set_table_name 'residential_energy_consumption_survey_responses'
8
-
9
7
  def zip_code_name=(value)
10
8
  self.zip_code = ZipCode.find_by_name(value)
11
9
  end
12
-
13
- def zip_code_name
14
- zip_code ? zip_code.name : nil
15
- end
16
-
17
- def rooms
18
- return nil unless ROOMS.collect {|t| t.first}.all? { |r| send r.to_s.pluralize.to_sym }
19
- ROOMS.map do |room|
20
- room_name = room[0]
21
- room_options = room[1]
22
- send(room_name.to_s.pluralize.to_sym).to_i * room_options[:multiplier]
23
- end.sum
24
- end
25
-
26
10
  def rooms=(room_count)
27
11
  raise ArgumentError, "Can't set rooms directly" unless room_count.nil?
28
12
  update_attributes ROOMS.inject({}) { |memo, r| memo[r[0].to_s.pluralize.to_sym] = nil; memo }
29
13
  end
30
-
31
- ADJECTIVES = %w(
32
- alluring
33
- beautiful
34
- charming
35
- dignified
36
- elegant
37
- fair
38
- graceful
39
- handsome
40
- inimitable
41
- j
42
- k
43
- lovely
44
- magnificent
45
- n
46
- o
47
- pretty
48
- q
49
- resplendent
50
- splendid
51
- t
52
- unparalleled
53
- v
54
- well-appointed
55
- x
56
- y
57
- z
58
- )
59
-
60
- ROOMS = [
61
- [:bedroom, { :max_count => 10, :multiplier => 1 }],
62
- [:living_room, { :max_count => 5, :multiplier => 1 }],
63
- [:dining_room, { :max_count => 3, :multiplier => 1 }],
64
- [:kitchen, { :max_count => 3, :multiplier => 1 }],
65
- [:full_bathroom, { :max_count => 10, :multiplier => 0.5 }],
66
- [:half_bathroom, { :max_count => 10, :multiplier => 0.25 }],
67
- [:heated_garage_berth, { :max_count => 5, :multiplier => 1 }],
68
- [:other_room, { :max_count => 10, :multiplier => 1 }]
69
- ]
70
14
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: residence
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 17
10
- version: 0.0.17
9
+ - 18
10
+ version: 0.0.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-12-02 00:00:00 -05:00
22
+ date: 2010-12-07 00:00:00 -06:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency