-
-
Save anonymous/53d88d8e2c83512cf163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.3p194 :003 > u = User.last | |
1.9.3p194 :003 > u.raw(u.male_list.sample(1), u.female_list.sample(1)) | |
TypeError: can't convert String into Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def conditions(male, female) | |
girl = female | |
boy = male | |
boy_age = Time.now.year - boy["birthday_date"][boy["birthday_date"].size, boy["birthday_date"]-4] | |
girl_age = Time.now.year - girl["birthday_date"][girl["birthday_date"].size, girl["birthday_date"]-4] | |
if ((boy_age+7)/2) < girl_age | |
false | |
elsif boy["name"].include?(girl["last_name"]) | |
false | |
# elsif boy[status] == 'relationship' || girl[status] == 'relationship' | |
# false | |
else | |
true | |
end | |
end | |
def raw(male, female) | |
female = female | |
male = male | |
if !conditions(male, female) | |
raw(current_user.male.sample(1), current_user.female.sample(1)) | |
else | |
perfect_match = [] | |
perfect_match << female | |
perfect_match << male | |
return perfect_match | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment