cre_property_matcher 0.0.1 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 617f73f0d0ce70224793a55dc6ac680990d95699
4
- data.tar.gz: f2a06e739e318e5b83cc6c59bf7f86cdcc3c6469
3
+ metadata.gz: b87ceea359fef0d415fab5b55d1b6924ec4ac83e
4
+ data.tar.gz: 786e572134dbd7ceba8f43c1fa95605c8631389d
5
5
  SHA512:
6
- metadata.gz: f23890b70af0eb32b9f7b857d01d0f234e44ea881722d3e3e9deb84e0235d5c20625b70bc1bfa7c089238520e93eb384463fa1d35816fca3b75baa659d60c5c8
7
- data.tar.gz: 3eb950eabe40c8e9951ec2dcb9a78abd9e976ff2b16876df5f1ca5294899429c317a846c5915fe42a99d1c0bfb3390d021d3819078b1b7fee97d2adefb756654
6
+ metadata.gz: e9ff9749f53624e142e75bd12ea1381ec546a0ebedf182355d66a33a68810143ff023ae70bf66eec2cc071f255c1573f2e6c7d2bd096b39609037f282da52820
7
+ data.tar.gz: d56cd26a7d4bd6abbfbb3735c12d0052efb42ba5dae8a40b3c6c9be8636b67020c382379268e89bcf55c3cf785a04dd7f62dfc885ce1a9b9fbfa5aa9835c14d0
@@ -0,0 +1,40 @@
1
+ require File.expand_path("../resources/state_hash.rb", __FILE__)
2
+ module PropertyDataCalculator
3
+
4
+ def get_average_by_reference_property_state(properties, reference, attribute)
5
+ state_properties = filter_properties_by_state(properties, reference.state)
6
+ values_array = get_attribute_from_properties(state_properties, attribute)
7
+ total = values_array.compact.reduce(:+)
8
+ total.to_f / values_array.count
9
+ end
10
+
11
+ private
12
+
13
+ def filter_properties_by_state(properties, state)
14
+ properties.select do |property|
15
+ normalize_state(property.state) == state.strip.downcase
16
+ end
17
+ end
18
+
19
+ def normalize_state(state)
20
+ if state.nil?
21
+ "nothing"
22
+ elsif state.length > 3
23
+ result = StateHash.state_hash[state.strip.capitalize]
24
+ if result.nil?
25
+ "nothing"
26
+ else
27
+ result.downcase
28
+ end
29
+ else
30
+ state.downcase
31
+ end
32
+ end
33
+
34
+ def get_attribute_from_properties(properties, attribute)
35
+ properties.map do |property|
36
+ property.instance_variable_get(:"@#{attribute}")
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,55 @@
1
+ module StateHash
2
+ def self.state_hash
3
+ {"Alabama" => "AL",
4
+ "Alaska" => "AK",
5
+ "Arizona" => "AZ",
6
+ "Arkansas" => "AR",
7
+ "California" => "CA",
8
+ "Colorado" => "CO",
9
+ "Connecticut" => "CT",
10
+ "Delaware" => "DE",
11
+ "District of Columbia" => "DC",
12
+ "Florida" => "FL",
13
+ "Georgia" => "GA",
14
+ "Hawaii" => "HI",
15
+ "Idaho" => "ID",
16
+ "Illinois" => "IL",
17
+ "Indiana" => "IN",
18
+ "Iowa" => "IA",
19
+ "Kansas" => "KS",
20
+ "Kentucky" => "KY",
21
+ "Louisiana" => "LA",
22
+ "Maine" => "ME",
23
+ "Maryland" => "MD",
24
+ "Massachusetts" => "MA",
25
+ "Michigan" => "MI",
26
+ "Minnesota" => "MN",
27
+ "Mississippi" => "MS",
28
+ "Missouri" => "MO",
29
+ "Montana" => "MT",
30
+ "Nebraska" => "NE",
31
+ "Nevada" => "NV",
32
+ "New Hampshire" => "NH",
33
+ "New Jersey" => "NJ",
34
+ "New Mexico" => "NM",
35
+ "New York" => "NY",
36
+ "North Carolina" => "NC",
37
+ "North Dakota" => "ND",
38
+ "Ohio" => "OH",
39
+ "Oklahoma" => "OK",
40
+ "Oregon" => "OR",
41
+ "Pennsylvania" => "PA",
42
+ "Rhode Island" => "RI",
43
+ "South Carolina" => "SC",
44
+ "South Dakota" => "SD",
45
+ "Tennessee" => "TN",
46
+ "Texas" => "TX",
47
+ "Utah" => "UT",
48
+ "Vermont" => "VT",
49
+ "Virginia" => "VA",
50
+ "Washington" => "WA",
51
+ "West Virginia" => "WV",
52
+ "Wisconsin" => "WI",
53
+ "Wyoming" => "WY"}
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module CrePropertyMatcher
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -1,8 +1,11 @@
1
1
  require File.expand_path("../cre_property_matcher/version.rb", __FILE__)
2
2
  require File.expand_path("../cre_property_matcher/property_data_loader.rb", __FILE__)
3
+ require File.expand_path("../cre_property_matcher/property_data_calculator.rb", __FILE__)
3
4
 
4
5
  module CrePropertyMatcher
5
6
  class PropertyMatcher
7
+ include PropertyDataCalculator
8
+
6
9
  attr_accessor :reference_property, :comparison_properties
7
10
 
8
11
  def initialize(reference_property)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cre_property_matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Arner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,9 @@ files:
55
55
  - lib/cre_property_matcher.rb
56
56
  - lib/cre_property_matcher/property.rb
57
57
  - lib/cre_property_matcher/property_attributes.rb
58
+ - lib/cre_property_matcher/property_data_calculator.rb
58
59
  - lib/cre_property_matcher/property_data_loader.rb
60
+ - lib/cre_property_matcher/resources/state_hash.rb
59
61
  - lib/cre_property_matcher/training_data/property_data.csv
60
62
  - lib/cre_property_matcher/version.rb
61
63
  homepage: ''