Sha256: 30de679cf3b76fafc3224da97f1c5eef12f952fded8f40ef5496a3da9d4d85a4

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

module Zodiac
  module Date
    def zodiac_sign
      raise "#{self} should respond_to #month and #day" unless respond_to?(:month) && respond_to?(:day)
      
      Finder.sign_for(month: self.month, day: self.day)
    end
    
    def zodiac_sign_id
      raise "#{self} should respond_to #month and #day" unless respond_to?(:month) && respond_to?(:day)
      
      Finder.sign_id_for(month: self.month, day: self.day)
    end
    
    Zodiac.each_sign do |symbol, integer|
      define_method("#{symbol}?") do        # def libra?
        self.zodiac_sign_id == integer      #   self.zodiac_sign_id == 7
      end                                   # end
    end
  end
end

[Time, Date, DateTime].each do |date_class|
  date_class.send(:include, Zodiac::Date) 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zodiac-0.2.6 lib/zodiac/date.rb