class Lookbook::PreviewDirectoryEntity
def children
def children @children ||= Previews.tree.children_of(self).sort end
def hidden?
def hidden? children.select(&:visible?).none? end
def id
def id @id ||= Utils.id(lookup_path) end
def initialize(lookup_path, default_priority: nil)
def initialize(lookup_path, default_priority: nil) @lookup_path = lookup_path @default_priority = default_priority @type = :directory end
def name
def name @name ||= lookup_path.split("/").pop end
def parent
def parent parent_lookup_path = File.dirname(lookup_path).delete_prefix(".") Previews.directories.find { _1.lookup_path == parent_lookup_path } end
def to_h
def to_h { entity: "directory", name: name, label: label, lookup_path: lookup_path, children: children.map(&:to_h) } end