Category (Class)

In: app/models/chunks/category.rb
Parent: Chunk::Abstract

The category chunk looks for "category: news" on a line by itself and parses the terms after the ’:’ as categories. Other classes can search for Category chunks within rendered content to find out what categories this page should be in.

Category lines can be hidden using ’:category: news’, for example

Methods

mask   new   pattern   unmask  

Attributes

hidden  [R] 
list  [R] 

Public Class methods

[Source]

    # File app/models/chunks/category.rb, line 15
15:   def initialize(match_data)
16:     super(match_data)
17:         @hidden = match_data[1]
18:     @list = match_data[2].split(',').map { |c| c.strip }
19:   end

[Source]

    # File app/models/chunks/category.rb, line 11
11:   def self.pattern() return /^(:)?category\s*:(.*)$/i end

Public Instance methods

Mark this chunk’s start and end points but allow the terms after the ’:’ to be marked up.

[Source]

    # File app/models/chunks/category.rb, line 23
23:   def mask(content) pre_mask + list.join(', ') + post_mask end

If the chunk is hidden, erase the mask and return this chunk otherwise, surround it with a ‘div’ block.

[Source]

    # File app/models/chunks/category.rb, line 27
27:   def unmask(content)
28:         replacement = ( hidden ? '' : '<div class="property">category:\1</div>' )
29:     self if content.sub!( Regexp.new( pre_mask+'(.*)?'+post_mask ), replacement )
30:   end

[Validate]