mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Add started?
and deep_titles
helper methods
This commit is contained in:
parent
3dc9bd2264
commit
e28dadc94e
@ -163,6 +163,10 @@ class Entry
|
||||
def finished?(username)
|
||||
load_progress(username) == @pages
|
||||
end
|
||||
|
||||
def started?(username)
|
||||
load_progress(username) > 0
|
||||
end
|
||||
end
|
||||
|
||||
class Title
|
||||
@ -257,6 +261,11 @@ class Title
|
||||
@entries + titles.map { |t| t.deep_entries }.flatten
|
||||
end
|
||||
|
||||
def deep_titles
|
||||
return [] of Title if titles.empty?
|
||||
titles + titles.map { |t| t.deep_titles }.flatten
|
||||
end
|
||||
|
||||
def parents
|
||||
ary = [] of Title
|
||||
tid = @parent_id
|
||||
@ -469,6 +478,10 @@ class Library
|
||||
@title_ids.map { |tid| self.get_title!(tid) }
|
||||
end
|
||||
|
||||
def deep_titles
|
||||
titles + titles.map { |t| t.deep_titles }.flatten
|
||||
end
|
||||
|
||||
def to_json(json : JSON::Builder)
|
||||
json.object do
|
||||
json.field "dir", @dir
|
||||
|
Loading…
x
Reference in New Issue
Block a user