Class: Yuzu::PostProcessors::ExcerptPostProcessor

Inherits:
PostProcessor show all
Defined in:
lib/yuzu/postprocessors/excerpt.rb

Instance Attribute Summary

Attributes inherited from PostProcessor

#name

Instance Method Summary collapse

Methods inherited from PostProcessor

postprocessors, registry, #value

Constructor Details

#initializeExcerptPostProcessor

Returns a new instance of ExcerptPostProcessor.



5
6
7
8
# File 'lib/yuzu/postprocessors/excerpt.rb', line 5

def initialize
  @name = :excerpt
  @directive = "EXCERPT"
end

Instance Method Details

#match(contents) ⇒ Object



15
16
17
18
19
# File 'lib/yuzu/postprocessors/excerpt.rb', line 15

def match(contents)
  num_paragraphs = 5
  m = contents.scan(regex)
  m.nil? ? "" : m[0...5].join
end

#regexObject



10
11
12
13
# File 'lib/yuzu/postprocessors/excerpt.rb', line 10

def regex
  # Grab the entire paragraph, with the tag.
  /<p\b[^>]*?>.*?<\/p>/n
end