Class: Faun::Topic

Inherits:
SectionWithMeta show all
Defined in:
lib/faun.rb

Instance Attribute Summary collapse

Attributes inherited from SectionWithMeta

#meta

Attributes inherited from Section

#id, #items, #name

Instance Method Summary collapse

Methods inherited from Section

#each, #each_key, #each_value, #to_json

Constructor Details

#initialize(id, name, path) ⇒ Topic

Returns a new instance of Topic.



105
106
107
108
109
110
111
# File 'lib/faun.rb', line 105

def initialize(id, name, path)
  super(id, name, path, Subtopic)

  @posts = @items.flat_map do |_, sub|
    sub.posts.to_a
  end.to_h
end

Instance Attribute Details

#postsObject (readonly)

Returns the value of attribute posts.



103
104
105
# File 'lib/faun.rb', line 103

def posts
  @posts
end

Instance Method Details

#item_nameObject



117
118
119
# File 'lib/faun.rb', line 117

def item_name
  "chapters"
end

#subtopic(subid) ⇒ Object



113
114
115
# File 'lib/faun.rb', line 113

def subtopic(subid)
  @items[subid]
end