lib/command/list.rb in narou-1.2.9 vs lib/command/list.rb in narou-1.3.0

- old
+ new

@@ -5,10 +5,12 @@ require_relative "../database" module Command class List < CommandBase + NEW_ARRIVALS_LIMIT = 6 * 60 * 60 # 更新してから何秒までを新着色にするか + def initialize super("[<number>] [options]") @opt.separator <<-EOS ・現在管理している小説の一覧を表示します。 @@ -33,22 +35,25 @@ @options["url"] = true } end def output_list(novels) - today = Time.now.strftime("%y/%m/%d") + now = Time.now + today = now.strftime("%y/%m/%d") puts " ID | 更新日 | タイトル" novels.each do |novel| id = novel["id"] frozen = Narou.novel_frozen?(id) disp_id = ((frozen ? "*" : "") + id.to_s).rjust(4) disp_id = disp_id.sub("*", "<cyan>*</cyan>").termcolor if frozen puts [ disp_id, novel["last_update"].strftime("%y/%m/%d").tap { |s| - if novel["new_arrivals_date"] && novel["new_arrivals_date"].strftime("%y/%m/%d") == today + if novel["new_arrivals_date"] && novel["new_arrivals_date"] + NEW_ARRIVALS_LIMIT >= now + # 新着表示色 s.replace "<bold><magenta>#{s}</magenta></bold>".termcolor elsif s == today + # 更新だけあった色 s.replace "<bold><green>#{s}</green></bold>".termcolor end }, novel["title"], @options["url"] ? novel["toc_url"] : nil