Module: IchigoIchie::Calendar

Defined in:
lib/ichigo_ichie/calendar.rb

Class Method Summary collapse

Class Method Details

.for_date(date_str, store) ⇒ Object



26
27
28
29
30
31
# File 'lib/ichigo_ichie/calendar.rb', line 26

def for_date(date_str, store)
  date = Date.parse(date_str)
  quote_for(date, store)
rescue Date::Error
  raise "Invalid date: '#{date_str}'. Use YYYY-MM-DD format."
end

.quote_for(date, store) ⇒ Object



11
12
13
14
15
16
# File 'lib/ichigo_ichie/calendar.rb', line 11

def quote_for(date, store)
  Seed.run(store) if store.count.zero?

  day_index = date.yday - 1
  store.get(day_index)
end

.today(store) ⇒ Object



18
19
20
# File 'lib/ichigo_ichie/calendar.rb', line 18

def today(store)
  quote_for(Date.today, store)
end

.tomorrow(store) ⇒ Object



22
23
24
# File 'lib/ichigo_ichie/calendar.rb', line 22

def tomorrow(store)
  quote_for(Date.today + 1, store)
end