class PropertyDataLoader

Public Class Methods

new(manner = :csv) click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 6
def initialize(manner = :csv)
        @manner = manner
        @properties = []
        @csv_data = nil
end
run_and_return_properties() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 12
def self.run_and_return_properties
        pdl = PropertyDataLoader.new
        pdl.run_and_return_properties
end

Public Instance Methods

add_property(property) click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 41
def add_property(property)
        if property.class == Property
                @properties << property
        else
                raise "Unable to Add Property because it is not of the Property Class"
        end
end
csv_to_properties() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 62
def csv_to_properties
        data.each do |row|
                property = Property.new(row)
                add_property(property)
        end
end
data() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 49
def data
        @csv_data
end
load_csv() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 58
def load_csv
        @csv_data = CSV.read(property_data_path, {headers: true})
end
properties() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 29
def properties
        @properties
end
property_array() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 33
def property_array
        result = []
        properties.each do |property|
                result << property
        end
        result
end
property_data_path() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 53
def property_data_path
        # File.expand_path("../training_data/large_property_data.csv", __FILE__)
        File.expand_path("../training_data/total_data_set.csv", __FILE__)
end
run() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 17
def run
        if @manner && @manner == :csv
                load_csv if data.nil?
                csv_to_properties
        end
end
run_and_return_properties() click to toggle source
# File lib/cre_property_matcher/property_data_loader.rb, line 24
def run_and_return_properties
        run
        property_array
end