class BahaiDate::Weekday

Constants

ENGLISH_EQUIVALENTS
TITLES
TITLES_EN
TITLES_HTML

Attributes

number[R]

Public Class Methods

new(number_arg) click to toggle source
# File lib/bahai_date/weekday.rb, line 10
def initialize(number_arg)
  validate number_arg
  @number = number_arg.to_i
end

Public Instance Methods

english_equivalent() click to toggle source
# File lib/bahai_date/weekday.rb, line 31
def english_equivalent
  ENGLISH_EQUIVALENTS[title_index]
end
html() click to toggle source
# File lib/bahai_date/weekday.rb, line 27
def html
  TITLES_HTML[title_index]
end
title() click to toggle source
# File lib/bahai_date/weekday.rb, line 19
def title
  TITLES[title_index]
end
to_s() click to toggle source
# File lib/bahai_date/weekday.rb, line 15
def to_s
  title
end
translation() click to toggle source
# File lib/bahai_date/weekday.rb, line 23
def translation
  TITLES_EN[title_index]
end

Private Instance Methods

title_index() click to toggle source
# File lib/bahai_date/weekday.rb, line 37
def title_index
  @number - 1
end
validate(number_arg) click to toggle source
# File lib/bahai_date/weekday.rb, line 41
def validate(number_arg)
  number = number_arg.to_i
  return if (1..7).include? number

  fail ArgumentError, "'#{number}' is not a valid weekday. Please use 1 to 7."
end