Method: WhatsOn::Tool#list
- Defined in:
- lib/whatson/tool.rb
#list ⇒ Object
note: use list and NOT print (otherwise built-in call to print is recursive and will crash!!!)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/whatson/tool.rb', line 34 def list ## note: use list and NOT print (otherwise built-in call to print is recursive and will crash!!!) today = Date.today puts '' puts '' puts "#{@config.title}:" puts '' on = EventDb::Model::Event.live( today ) on.each do |e| print " NOW ON #{e.current_day(today)}d " print "#{e.title}" print " #{e.start_date.year}" if @config.show_year print ", " print "#{e.date_fmt} (#{e.days}d) @ #{e.place}" print "\n" end puts '' if on.any? ## get next 17 events up = EventDb::Model::Event.limit( 17 ).upcoming( today ) ## pp up.to_sql ## pp up if up.count > 0 up.each do |e| print " in #{e.diff_days(today)}d " print "#{e.title}" print " #{e.start_date.year}" if @config.show_year print ", " print "#{e.date_fmt} (#{e.days}d) @ #{e.place}" print "\n" end else puts " -- No upcoming events found. #{EventDb::Model::Event.count} past event(s) in database. --" end puts '' if @config.more_link puts " More @ #{@config.more_link}" puts '' end end |