Class: Madness::Directory
- Inherits:
-
Object
- Object
- Madness::Directory
- Includes:
- ServerHelper
- Defined in:
- lib/madness/directory.rb
Overview
Represents a directory with markdown file sand subflders.
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(dir) ⇒ Directory
constructor
A new instance of Directory.
- #list ⇒ Object
- #tree ⇒ Object
Methods included from ServerHelper
#disallowed_static?, #docroot, #find_static_file, #log, #theme
Constructor Details
#initialize(dir) ⇒ Directory
Returns a new instance of Directory.
11 12 13 |
# File 'lib/madness/directory.rb', line 11 def initialize(dir) @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/madness/directory.rb', line 9 def dir @dir end |
Instance Method Details
#list ⇒ Object
15 16 17 |
# File 'lib/madness/directory.rb', line 15 def list @list ||= (dirs + files) end |
#tree ⇒ Object
19 20 21 22 23 24 |
# File 'lib/madness/directory.rb', line 19 def tree @tree ||= list.map do |item| item.children = self.class.new(item.path).tree if item.dir? item end end |