Class: BahaiDate::Year

Inherits:
Object
  • Object
show all
Defined in:
lib/bahai_date/year.rb

Direct Known Subclasses

YearCalendar

Constant Summary collapse

TITLES =
%w(Alif Ba Ab Dal Bab Vav Abad Jad Baha Hubb Bahhaj Javab Ahad Vahhab Vidad Badi Bahi Abha Vahid)
TITLES_HTML =
%w(Alif Bá’ Ab Dál Báb Váv Abad Jád Bahá Ḥubb Bahháj Javáb Aḥad Vahháb Vidád Badí‘ Bahí Abhá Váḥid)
TITLES_EN =
%w(A B Father D Gate V Eternity Generosity Splendour Love Delightful Answer Single Bountiful Affection Beginning Luminous Most Luminous Unity)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number_arg) ⇒ Year

Returns a new instance of Year.



9
10
11
12
13
14
# File 'lib/bahai_date/year.rb', line 9

def initialize(number_arg)
  validate number_arg
  @bahai_era = number_arg.to_i
  calculate_number_vahid_and_kull_i_shay
  @months = {}
end

Instance Attribute Details

#bahai_eraObject (readonly)

Returns the value of attribute bahai_era.



7
8
9
# File 'lib/bahai_date/year.rb', line 7

def bahai_era
  @bahai_era
end

#kull_i_shayObject (readonly)

Returns the value of attribute kull_i_shay.



7
8
9
# File 'lib/bahai_date/year.rb', line 7

def kull_i_shay
  @kull_i_shay
end

#monthsObject (readonly)

Returns the value of attribute months.



7
8
9
# File 'lib/bahai_date/year.rb', line 7

def months
  @months
end

#numberObject (readonly)

Returns the value of attribute number.



7
8
9
# File 'lib/bahai_date/year.rb', line 7

def number
  @number
end

#vahidObject (readonly)

Returns the value of attribute vahid.



7
8
9
# File 'lib/bahai_date/year.rb', line 7

def vahid
  @vahid
end

Instance Method Details

#add_month(month_number) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/bahai_date/year.rb', line 32

def add_month(month_number)
  if @months[month_number]
    @months[month_number]
  else
    @months[month_number] = Month.new(month_number)
  end
end

#htmlObject



28
29
30
# File 'lib/bahai_date/year.rb', line 28

def html
  TITLES_HTML[title_index]
end

#titleObject



20
21
22
# File 'lib/bahai_date/year.rb', line 20

def title
  TITLES[title_index]
end

#to_sObject



16
17
18
# File 'lib/bahai_date/year.rb', line 16

def to_s
  @bahai_era.to_s
end

#translationObject



24
25
26
# File 'lib/bahai_date/year.rb', line 24

def translation
  TITLES_EN[title_index]
end