Module: Birthgem

Defined in:
lib/birthgem.rb,
lib/birthgem/version.rb

Overview

This module lets you know the birstone(s) for an entered birthday.

Constant Summary collapse

STONE_BY_MONTH =

The birthstones are selected according to [International Gem Society](www.gemsociety.org/article/birthstone-chart/).

{
  1 => %w[Garnet],
  2 => %w[Amethyst],
  3 => %w[Aquamarine],
  4 => %w[Diamond],
  5 => %w[Emerald],
  6 => %w[Pearl Alexandrite],
  7 => %w[Ruby],
  8 => %w[Peridot],
  9 => %w[Sapphire],
  10 => %w[Opal Tourmaline],
  11 => %w[Citrine],
  12 => ['Blue Topaz', 'Tanzanite', 'Blue Zircon']
}.freeze
VERSION =
'2.0.0'

Class Method Summary collapse

Class Method Details

.stone(date) ⇒ Object

Outputs the birthstone(s) of the month for the date in the argument.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/birthgem.rb', line 30

def self.stone(date)
  key =
    if date.instance_of?(Integer)
      date
    elsif date.instance_of?(String)
      parsed_date = Date.parse(date)
      parsed_date.month
    elsif date.instance_of?(Date)
      date.month
    end
  STONE_BY_MONTH[key] unless key.nil?
end