class BahaiDate::Month

Constants

TITLES
TITLES_EN
TITLES_HTML

Attributes

days[R]
number[R]

Public Class Methods

new(number_arg) click to toggle source
# File lib/bahai_date/month.rb, line 9
def initialize(number_arg)
  validate number_arg
  @number = number_arg.to_i
  @days = {}
end

Public Instance Methods

add_day(day_number) click to toggle source
# File lib/bahai_date/month.rb, line 31
def add_day(day_number)
  return if @days[day_number]
  @days[day_number] = Day.new(day_number)
end
html() click to toggle source
# File lib/bahai_date/month.rb, line 27
def html
  TITLES_HTML[title_index]
end
title() click to toggle source
# File lib/bahai_date/month.rb, line 19
def title
  TITLES[title_index]
end
to_s() click to toggle source
# File lib/bahai_date/month.rb, line 15
def to_s
  title
end
translation() click to toggle source
# File lib/bahai_date/month.rb, line 23
def translation
  TITLES_EN[title_index]
end

Private Instance Methods

title_index() click to toggle source
# File lib/bahai_date/month.rb, line 38
def title_index
  if @number == -1
    19 # 20th element of the array
  else
    @number - 1
  end
end
validate(number_arg) click to toggle source
# File lib/bahai_date/month.rb, line 46
def validate(number_arg)
  number = number_arg.to_i
  return if (1..19).include?(number) || number == -1
  fail ArgumentError, "'#{number}' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
end