class Tag

Attributes

category[RW]
key[RW]
name[RW]
url[RW]

Public Class Methods

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

Public Instance Methods

build_html() click to toggle source
# File lib/zarchitect/tag.rb, line 19
def build_html
  @index.build_html
end
posts() click to toggle source
# File lib/zarchitect/tag.rb, line 13
def posts
  @category.section.posts.select do |p|
    ((p.category == @category) && (p.tags.include?(@name)))
  end
end
write_html() click to toggle source
# File lib/zarchitect/tag.rb, line 23
def write_html
  @index.write_html
end

Private Instance Methods

create_dir() click to toggle source
# File lib/zarchitect/tag.rb, line 29
def create_dir
  Util.mkdir(File.join(HTMLDIR, @category.section.key, @category.key, @key))
end
hash(str) click to toggle source
# File lib/zarchitect/tag.rb, line 37
def hash(str)
  str2 = String.new
  str.each_char do |c|
    str2 << c.ord.to_s
  end
  str2 = str2.to_i
  str2.to_s(16).downcase
end
setup_index() click to toggle source
# File lib/zarchitect/tag.rb, line 33
def setup_index
  @index = Index.new(self)
end