Class: Zmanim::HebrewCalendar::HebrewDateFormatter
- Inherits:
-
Object
- Object
- Zmanim::HebrewCalendar::HebrewDateFormatter
- Extended by:
- Util::TextHelper
- Includes:
- Util::HebrewNumericFormatter
- Defined in:
- lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb
Constant Summary collapse
- HEBREW_OMER_PREFIX =
'ב'
- FORMATTED_DAYS_OF_WEEK =
{ transliterated: Date::DAYNAMES[0..-2] + ['Shabbos'], hebrew: %w(ראשון שני שלישי רביעי חמישי ששי שבת) }
- FORMATTED_MONTHS =
{ transliterated: Zmanim::HebrewCalendar::JewishCalendar::MONTHS.each_with_object({}){|m, h| h[m] = titleize(m) }.merge(adar_i: 'Adar I', adar_ii: 'Adar II'), hebrew: { nissan: 'ניסן', iyar: 'אייר', sivan: 'סיון', tammuz: 'תמוז', av: 'אב', elul: 'אלול', tishrei: 'תשרי', cheshvan: 'חשון', kislev: 'כסלו', teves: 'טבת', shevat: 'שבט', adar: 'אדר', adar_i: 'אדר א', adar_ii: 'אדר ב' } }
- FORMATTED_SIGNIFICANT_DAYS =
{ transliterated: Zmanim::HebrewCalendar::JewishCalendar::SIGNIFICANT_DAYS.each_with_object({}){|d, h| h[d] = titleize(d) }.merge(tzom_gedalyah: 'Fast of Gedalyah', tenth_of_teves: 'Tenth of Teves', tu_beshvat: "Tu B'Shvat", taanis_esther: 'Fast of Esther', lag_baomer: "Lag B'Omer", seventeen_of_tammuz: 'Seventeenth of Tammuz', tisha_beav: "Tisha B'Av", tu_beav: "Tu B'Av", yom_hashoah: 'Yom HaShoah', yom_haatzmaut: "Yom Ha'atzmaut"), hebrew: { erev_rosh_hashana: 'ערב ראש השנה', rosh_hashana: 'ראש השנה', tzom_gedalyah: 'צום גדליה', erev_yom_kippur: 'ערב יום כיפור', yom_kippur: 'יום כיפור', erev_succos: 'ערב סוכות', succos: 'סוכות', chol_hamoed_succos: 'חול המועד סוכות', hoshana_rabbah: 'הושענה רבה', shemini_atzeres: 'שמיני עצרת', simchas_torah: 'שמחת תורה', chanukah: 'חנוכה', tenth_of_teves: 'עשרה בטבת', tu_beshvat: 'ט״ו בשבט', taanis_esther: 'תענית אסתר', purim: 'פורים', shushan_purim: 'שושן פורים', purim_katan: 'פורים קטן', shushan_purim_katan: 'שושן פורים קטן', erev_pesach: 'ערב פסח', pesach: 'פסח', chol_hamoed_pesach: 'חול המועד פסח', pesach_sheni: 'פסח שני', lag_baomer: 'ל״ג בעומר', erev_shavuos: 'ערב שבועות', shavuos: 'שבועות', seventeen_of_tammuz: 'שבעה עשר בתמוז', tisha_beav: 'תשעה באב', tu_beav: 'ט״ו באב', yom_hashoah: 'יום השואה', yom_hazikaron: 'יום הזכרון', yom_haatzmaut: 'יום העצמאות', yom_yerushalayim: 'יום ירושלים', } }
- FORMATTED_SIGNIFICANT_TEFILOS =
{ transliterated: Zmanim::HebrewCalendar::JewishCalendar::SIGNIFICANT_TEFILOS.each_with_object({}){|d, h| h[d] = titleize(d) }.merge(begin_mashiv_haruach: 'Mashiv Haruach (beginning Mussaf)', end_mashiv_haruach: 'Mashiv Haruach (ending Mussaf)', begin_morid_hatal: 'Morid Hatal (beginning Mussaf)'), hebrew: { yaaleh_veyavo: 'יעלה ויבא', al_hanissim: 'על הנסים', begin_mashiv_haruach: 'משיב הרוח (מתחילים במוסף)', end_mashiv_haruach: 'משיב הרוח (מסיימים במוסף)', mashiv_haruach: 'משיב הרוח', begin_morid_hatal: 'מוריד הטל (מתחילים במוסף)', morid_hatal: 'מוריד הטל', vesein_tal_umatar: 'ותן טל ומטר', vesein_beracha: 'ותן ברכה', atah_yatzarta: 'אתה יצרת', borchi_nafshi: 'ברכי נפשי', } }
- FORMATTED_SIGNIFICANT_SHABBOSOS =
{ transliterated: Zmanim::HebrewCalendar::JewishCalendar::SIGNIFICANT_SHABBOS.each_with_object({}){|d, h| h[d] = titleize(d) }, hebrew: { parshas_shekalim: 'פרשת שקלים', parshas_zachor: 'פרשת זכור', parshas_parah: 'פרשת פרה', parshas_hachodesh: 'פרשת החדש', shabbos_hagadol: 'שבת הגדול', shabbos_shuva: 'שבת שובה', } }
Constants included from Util::HebrewNumericFormatter
Util::HebrewNumericFormatter::GERESH, Util::HebrewNumericFormatter::GERSHAYIM
Instance Attribute Summary collapse
-
#hebrew_days_of_week ⇒ Object
Returns the value of attribute hebrew_days_of_week.
-
#hebrew_format ⇒ Object
Returns the value of attribute hebrew_format.
-
#hebrew_months ⇒ Object
Returns the value of attribute hebrew_months.
-
#hebrew_omer_prefix ⇒ Object
Returns the value of attribute hebrew_omer_prefix.
-
#hebrew_significant_days ⇒ Object
Returns the value of attribute hebrew_significant_days.
-
#hebrew_significant_shabbosos ⇒ Object
Returns the value of attribute hebrew_significant_shabbosos.
-
#hebrew_significant_tefilos ⇒ Object
Returns the value of attribute hebrew_significant_tefilos.
-
#long_week_format ⇒ Object
Returns the value of attribute long_week_format.
-
#transliterated_days_of_week ⇒ Object
Returns the value of attribute transliterated_days_of_week.
-
#transliterated_months ⇒ Object
Returns the value of attribute transliterated_months.
-
#transliterated_significant_days ⇒ Object
Returns the value of attribute transliterated_significant_days.
-
#transliterated_significant_shabbosos ⇒ Object
Returns the value of attribute transliterated_significant_shabbosos.
-
#transliterated_significant_tefilos ⇒ Object
Returns the value of attribute transliterated_significant_tefilos.
-
#use_long_hebrew_years ⇒ Object
Returns the value of attribute use_long_hebrew_years.
Attributes included from Util::HebrewNumericFormatter
Instance Method Summary collapse
- #format(date) ⇒ Object
- #format_day_of_week(date) ⇒ Object
- #format_hebrew_number(number) ⇒ Object
- #format_kviah(year) ⇒ Object
- #format_month(date) ⇒ Object
- #format_omer(calendar) ⇒ Object
- #format_rosh_chodesh(calendar) ⇒ Object
- #format_significant_day(calendar) ⇒ Object
- #format_significant_shabbos(calendar) ⇒ Object
- #format_tefilah_additions(calendar, customs = {walled_city: false, nusach: :ashkenaz}) ⇒ Object
-
#initialize ⇒ HebrewDateFormatter
constructor
A new instance of HebrewDateFormatter.
Methods included from Util::TextHelper
Constructor Details
#initialize ⇒ HebrewDateFormatter
Returns a new instance of HebrewDateFormatter.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 123 def initialize super # hebrew numeric formatter @long_week_format = true @transliterated_days_of_week = FORMATTED_DAYS_OF_WEEK[:transliterated] @transliterated_months = FORMATTED_MONTHS[:transliterated] @transliterated_significant_days = FORMATTED_SIGNIFICANT_DAYS[:transliterated] @transliterated_significant_tefilos = FORMATTED_SIGNIFICANT_TEFILOS[:transliterated] @transliterated_significant_shabbosos = FORMATTED_SIGNIFICANT_SHABBOSOS[:transliterated] @hebrew_days_of_week = FORMATTED_DAYS_OF_WEEK[:hebrew] @hebrew_months = FORMATTED_MONTHS[:hebrew] @hebrew_significant_days = FORMATTED_SIGNIFICANT_DAYS[:hebrew] @hebrew_significant_tefilos = FORMATTED_SIGNIFICANT_TEFILOS[:hebrew] @hebrew_significant_shabbosos = FORMATTED_SIGNIFICANT_SHABBOSOS[:hebrew] @hebrew_omer_prefix = HEBREW_OMER_PREFIX end |
Instance Attribute Details
#hebrew_days_of_week ⇒ Object
Returns the value of attribute hebrew_days_of_week.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_days_of_week @hebrew_days_of_week end |
#hebrew_format ⇒ Object
Returns the value of attribute hebrew_format.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_format @hebrew_format end |
#hebrew_months ⇒ Object
Returns the value of attribute hebrew_months.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_months @hebrew_months end |
#hebrew_omer_prefix ⇒ Object
Returns the value of attribute hebrew_omer_prefix.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_omer_prefix @hebrew_omer_prefix end |
#hebrew_significant_days ⇒ Object
Returns the value of attribute hebrew_significant_days.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_significant_days @hebrew_significant_days end |
#hebrew_significant_shabbosos ⇒ Object
Returns the value of attribute hebrew_significant_shabbosos.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_significant_shabbosos @hebrew_significant_shabbosos end |
#hebrew_significant_tefilos ⇒ Object
Returns the value of attribute hebrew_significant_tefilos.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def hebrew_significant_tefilos @hebrew_significant_tefilos end |
#long_week_format ⇒ Object
Returns the value of attribute long_week_format.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def long_week_format @long_week_format end |
#transliterated_days_of_week ⇒ Object
Returns the value of attribute transliterated_days_of_week.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def transliterated_days_of_week @transliterated_days_of_week end |
#transliterated_months ⇒ Object
Returns the value of attribute transliterated_months.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def transliterated_months @transliterated_months end |
#transliterated_significant_days ⇒ Object
Returns the value of attribute transliterated_significant_days.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def transliterated_significant_days @transliterated_significant_days end |
#transliterated_significant_shabbosos ⇒ Object
Returns the value of attribute transliterated_significant_shabbosos.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def transliterated_significant_shabbosos @transliterated_significant_shabbosos end |
#transliterated_significant_tefilos ⇒ Object
Returns the value of attribute transliterated_significant_tefilos.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def transliterated_significant_tefilos @transliterated_significant_tefilos end |
#use_long_hebrew_years ⇒ Object
Returns the value of attribute use_long_hebrew_years.
11 12 13 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 11 def use_long_hebrew_years @use_long_hebrew_years end |
Instance Method Details
#format(date) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 139 def format(date) if hebrew_format format_hebrew_number(date.jewish_day) + ' ' + format_month(date) + ' ' + format_hebrew_number(date.jewish_year) else "#{date.jewish_day} #{format_month(date)}, #{date.jewish_year}" end end |
#format_day_of_week(date) ⇒ Object
151 152 153 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 151 def format_day_of_week(date) format_day_of_week_from_number(date.day_of_week) end |
#format_hebrew_number(number) ⇒ Object
155 156 157 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 155 def format_hebrew_number(number) super(number, use_long_hebrew_years) end |
#format_kviah(year) ⇒ Object
187 188 189 190 191 192 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 187 def format_kviah(year) date = year.is_a?(Numeric) ? Zmanim::HebrewCalendar::JewishDate.new(year, 7, 1) : year kviah_values = date.kviah kviah_glyph = {chaseirim: 'ח', kesidran: 'כ', shelaimim: 'ש'}[kviah_values[:kviah]] "#{format_hebrew_number(kviah_values[:rosh_hashana])}#{kviah_glyph}#{format_hebrew_number(kviah_values[:pesach])}".delete(GERESH) end |
#format_month(date) ⇒ Object
147 148 149 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 147 def format_month(date) format_month_from_name(date.jewish_month_name, date.jewish_leap_year?) end |
#format_omer(calendar) ⇒ Object
178 179 180 181 182 183 184 185 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 178 def format_omer(calendar) return '' unless number = calendar.day_of_omer if hebrew_format format_hebrew_number(number) + ' ' + hebrew_omer_prefix + 'עומר' else number == 33 ? "Lag B'Omer" : "Omer #{number}" end end |
#format_rosh_chodesh(calendar) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 166 def format_rosh_chodesh(calendar) return '' unless calendar.rosh_chodesh? || calendar.erev_rosh_chodesh? month = calendar.jewish_month day = calendar.jewish_day if day != 1 month += 1 month = 1 if month > calendar.months_in_jewish_year end month_name = calendar.jewish_month_name(month) formatted_rosh_chodesh(calendar.erev_rosh_chodesh?) + ' ' + format_month_from_name(month_name, calendar.jewish_leap_year?) end |
#format_significant_day(calendar) ⇒ Object
159 160 161 162 163 164 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 159 def format_significant_day(calendar) sd = calendar.significant_day return '' unless sd prefix = (day_number = calendar.day_of_chanukah) ? formatted_number(day_number) + ' ' : '' prefix + formatted_significant_day(sd) end |
#format_significant_shabbos(calendar) ⇒ Object
203 204 205 206 207 208 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 203 def format_significant_shabbos(calendar) return '' unless shabbos = calendar.significant_shabbos hebrew_format ? hebrew_significant_shabbosos[shabbos] : transliterated_significant_shabbosos[shabbos] end |
#format_tefilah_additions(calendar, customs = {walled_city: false, nusach: :ashkenaz}) ⇒ Object
194 195 196 197 198 199 200 201 |
# File 'lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb', line 194 def format_tefilah_additions(calendar, customs={walled_city: false, nusach: :ashkenaz}) additions = calendar.tefilah_additions(walled_city: customs[:walled_city], nusach: customs[:nusach]) additions.map do |addition| hebrew_format ? hebrew_significant_tefilos[addition] : transliterated_significant_tefilos[addition] end end |