class Category

Attributes

key[R]
name[R]
section[R]
tags[R]
url[R]

Public Class Methods

new(key, name, section) click to toggle source
# File lib/zarchitect/category.rb, line 4
def initialize(key, name, section)
  @key = key
  @name = name
  @section = section
  @url  = "/#{@section.key}/#{@key}/index.html"

  create_dir
end

Public Instance Methods

build_html() click to toggle source
# File lib/zarchitect/category.rb, line 13
def build_html
  if @tags
    @tags.each do |t|
      t.build_html
    end
  end
  @index.build_html
end
fetch_tags() click to toggle source
# File lib/zarchitect/category.rb, line 31
def fetch_tags
  # after fetch_pages is implemented
  ar = Array.new
  posts.each do |p|
    if p.conf.has_option?("tags")
      p.conf.tags.each { |t| ar.push t }
    end
  end
  ar.sort!.uniq!
  if ar.count == 0
    @tags = nil
  else
    @tags = Array.new
    ar.each { |v| @tags.push Tag.new(v, self) }
  end
end
posts() click to toggle source
# File lib/zarchitect/category.rb, line 48
def posts
  @section.posts.select { |p| p.category == self }
end
setup_index() click to toggle source
# File lib/zarchitect/category.rb, line 52
def setup_index
  @index = Index.new(self)
end
write_html() click to toggle source
# File lib/zarchitect/category.rb, line 22
def write_html
  if @tags
    @tags.each do |t|
      t.write_html
    end
  end
  @index.write_html
end

Private Instance Methods

create_dir() click to toggle source
# File lib/zarchitect/category.rb, line 58
def create_dir
  Util.mkdir(File.join(HTMLDIR, @section.key, @key))
end