Skip to content

Instantly share code, notes, and snippets.

@febuiles
Created November 19, 2008 06:43
Show Gist options
  • Select an option

  • Save febuiles/26439 to your computer and use it in GitHub Desktop.

Select an option

Save febuiles/26439 to your computer and use it in GitHub Desktop.
module ZodiacHelper
def zodiac_sign_for(date)
if date.respond_to?(:strftime)
birth = date.strftime("%m%d").to_i # month/day as an integer
else
birth = date
end
case birth
when 11..120 then zodiac = "Capricorn"
when 121..219 then zodiac = "Aquarius"
when 220..320 then zodiac = "Pisces"
when 321..420 then zodiac = "Aries"
when 421..521 then zodiac = "Taurus"
when 522..621 then zodiac = "Gemini"
when 622..722 then zodiac = "Cancer"
when 723..821 then zodiac = "Leo"
when 822..923 then zodiac = "Virgo"
when 924..1023 then zodiac = "Libra"
when 1024..1122 then zodiac = "Scorpio"
when 1123..1222 then zodiac = "Sagittarius"
when 1223..1231 then zodiac = "Capricorn"
else
raise "Invalid date for zodiac sign - #{date}"
end
zodiac
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment