Class: Nwiki::Core::Directory

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, list) ⇒ Directory

Returns a new instance of Directory.



10
11
12
13
14
15
# File 'lib/nwiki/core/directory.rb', line 10

def initialize path, list
  @path = path
  @list = list.
    select { |e| e =~ /\.org$/ }.
    map { |e| e.sub(/\.org$/){ '' } }
end

Class Attribute Details

.encodingObject

Returns the value of attribute encoding.



5
6
7
# File 'lib/nwiki/core/directory.rb', line 5

def encoding
  @encoding
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



8
9
10
# File 'lib/nwiki/core/directory.rb', line 8

def list
  @list
end

Instance Method Details

#encodingObject



21
22
23
# File 'lib/nwiki/core/directory.rb', line 21

def encoding
  self.class.encoding
end

#titleObject



17
18
19
# File 'lib/nwiki/core/directory.rb', line 17

def title
  @path
end

#to_htmlObject



25
26
27
28
29
30
31
# File 'lib/nwiki/core/directory.rb', line 25

def to_html
  '<ul>' + @list.map { |e|
    root = './'
    root << @path if @path != '/'
    %Q!<li><a href="#{root}#{e.gsub('#', '%23')}">#{e}</a></li>!
  }.join + '</ul>'
end