From 9114c0b4880bdae56e4871eb82a8e05e18a337a3 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 14 Feb 2020 16:29:38 +0000 Subject: [PATCH] - do not show entries containing no pages --- src/library.cr | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library.cr b/src/library.cr index a0d8dcb..8e0fcca 100644 --- a/src/library.cr +++ b/src/library.cr @@ -63,8 +63,9 @@ class Title @dir = dir @title = File.basename dir @entries = (Dir.entries dir) - .select! { |path| (File.extname path) == ".zip" } + .select { |path| (File.extname path) == ".zip" } .map { |path| Entry.new File.join(dir, path), @title } + .select { |e| e.pages > 0 } .sort { |a, b| a.title <=> b.title } end def get_entry(name) @@ -145,9 +146,9 @@ class Library Dir.mkdir_p dir end @titles = (Dir.entries dir) - .select! { |path| File.directory? File.join dir, path } + .select { |path| File.directory? File.join dir, path } .map { |path| Title.new File.join dir, path } - .select! { |title| !title.entries.empty? } + .select { |title| !title.entries.empty? } end def get_title(name) @titles.find { |t| t.title == name }