Method: MenuWindow#draw_title

Defined in:
lib/menu_window.rb

#draw_titleObject

TODO put the date range of the items in the title



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/menu_window.rb', line 57

def draw_title
  @title_box.clear
  
  # This handles a list of feeds, which don't really have a date range
  unless @items.first && @items.first.respond_to?(:date_published)
    @title_box.addstr(@title)
    @title_box.refresh
    return
  end

  # Get the date range from the items in the page content
  dates = @page_content.map {|x| x[:item]}.map {|i| 
    if i.respond_to?(:date_published)
     i.date_published 
    elsif i.respond_to?(:last_updated)
     i.last_updated 
    end
  }
  most_recent_date = dates.max.strftime('%B %d %Y')
  oldest_date = dates.min.strftime('%B %d %Y')

  if most_recent_date != oldest_date 
    @title_box.addstr(@title + " | " + oldest_date + " - " + most_recent_date)
  else
    @title_box.addstr(@title + " | " + oldest_date)
  end
  @title_box.refresh
end