Use is_valid?

This commit is contained in:
Alex Ling
2022-05-22 05:12:43 +00:00
parent 872e6dc6d6
commit e6dbeb623b
5 changed files with 21 additions and 8 deletions
+11 -2
View File
@@ -28,8 +28,7 @@ abstract class Entry
if err_msg
json.field "err_msg", err_msg
end
# for API backward compatability
json.field "zip_path", path
json.field "zip_path", path # for API backward compatability
json.field "title_id", @book.id
json.field "title_title", @book.title
json.field "sort_title", sort_title
@@ -220,6 +219,16 @@ abstract class Entry
date_added.not_nil! # is it ok to set not_nil! here?
end
# Hack to have abstract class methods
# https://github.com/crystal-lang/crystal/issues/5956
private module ClassMethods
abstract def is_valid?(path : String) : Bool
end
macro inherited
extend ClassMethods
end
abstract def path : String
abstract def read_page(page_num)