Class: Aardi::Tags

Inherits:
AbstractBlog show all
Defined in:
lib/aardi/tags.rb

Instance Attribute Summary

Attributes inherited from AbstractBlog

#key

Instance Method Summary collapse

Methods inherited from AbstractBlog

#metadata, #mtime, #render

Constructor Details

#initializeTags

Returns a new instance of Tags.



5
6
7
# File 'lib/aardi/tags.rb', line 5

def initialize
  @index = Hash.new { |hash, tag| hash[tag] = TagBlog.new(tag) }
end

Instance Method Details

#<<(post) ⇒ Object



9
10
11
12
13
# File 'lib/aardi/tags.rb', line 9

def <<(post)
  post.tags&.each do |tag|
    @index[tag] << post
  end
end

#contentObject



15
16
17
18
19
# File 'lib/aardi/tags.rb', line 15

def content
  return "# Tags\n" if counts.empty?

  "# Tags\n\n#{tag_lines.join("\n")}\n"
end

#empty?Boolean

Returns:

  • (Boolean)


21
# File 'lib/aardi/tags.rb', line 21

def empty? = @index.empty?


23
24
25
# File 'lib/aardi/tags.rb', line 23

def inline_links
  counts.map { |_tag, tag_blog| tag_blog.inline_link_text }.join(', ')
end

#target_pathObject



27
28
29
# File 'lib/aardi/tags.rb', line 27

def target_path
  "./#{tags_base_path}/index.html"
end

#titleObject



31
# File 'lib/aardi/tags.rb', line 31

def title = 'Tags'