zodiac is a ruby library for finding one’s zodiac sign by a date of birth.
$ gem install zodiac
# Gemfile gem 'zodiac'
require 'zodiac' Time.now.zodiac_sign # => "Aries" require 'date' Date.new(2011, 1, 1).zodiac_sign # => "Capricorn" DateTime.new(2011, 4, 30).zodiac_sign # => "Taurus"
Zodiac sign names are retrieved from
I18n and can be added to standard locales if your language isn’t yet supported by the gem.
Date.new(1989, 2, 26).pisces? # => true Time.gm(1978, 7, 12).gemini? # => false
Suppose you have a date of birth in
# app/models/person.rb class Person < ActiveRecord::Base zodiac_reader :dob end
Person instances have the same zodiac functionality as
@person = Person.first @person.zodiac_sign # => "Taurus" @person.libra? # => false @person.taurus? # => true
ActiveRecord searching by zodiac sign
$ rails generate zodiac:migration Person $ rake db:migrate
Person.with_zodiac_sign('libra') # returns all libras Person.gemini # all the geminis
- en (English)
- ru (Russian)
- pt-BR (Brazilian Portuguese)
- ja (Japanese)
- it (Italian)
- es (Spanish)
- de (German)
- zh-CN (Chinese)
- fr (French)
- lv (Latvian)
- zh-TW (Traditional Chinese)
- uk (Ukrainian)