Class: Madman::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/madman/directory.rb

Overview

Represents a directory with markdown files and subflders.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, basedir = nil) ⇒ Directory

Returns a new instance of Directory.



6
7
8
9
# File 'lib/madman/directory.rb', line 6

def initialize(dir, basedir = nil)
  @dir = dir
  @basedir = basedir || dir
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



4
5
6
# File 'lib/madman/directory.rb', line 4

def basedir
  @basedir
end

#dirObject (readonly)

Returns the value of attribute dir.



4
5
6
# File 'lib/madman/directory.rb', line 4

def dir
  @dir
end

Instance Method Details

#deep_listObject



15
16
17
18
19
20
21
# File 'lib/madman/directory.rb', line 15

def deep_list
  result = list
  dirs.each do |dir|
    result += Directory.new(dir.path, basedir).deep_list
  end
  result
end

#listObject



11
12
13
# File 'lib/madman/directory.rb', line 11

def list
  @list ||= (dirs + files)
end