Method: Faun::Section#initialize

Defined in:
lib/faun.rb

#initialize(id, name, path, type) ⇒ Section

Returns a new instance of Section.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/faun.rb', line 15

def initialize(id, name, path, type)
  @id = id
  @name = name

  subs = {}
  Dir.each_child(path) do |section|
    dir = File.join(path, section)
    next unless File.directory?(dir) and not section.start_with?('.')

    name, _, id = section.rpartition(".@")
    id = id.to_i
    subs[id] = type.new(id, name, dir)
  end
  @items = subs.sort_by { |subid, _| subid }.to_h
end