Class: Yuzu::PostProcessors::ExcerptPostProcessor
- Inherits:
-
PostProcessor
- Object
- Register
- PostProcessor
- Yuzu::PostProcessors::ExcerptPostProcessor
- Defined in:
- lib/yuzu/postprocessors/excerpt.rb
Instance Attribute Summary
Attributes inherited from PostProcessor
Instance Method Summary collapse
-
#initialize ⇒ ExcerptPostProcessor
constructor
A new instance of ExcerptPostProcessor.
- #match(contents) ⇒ Object
- #regex ⇒ Object
Methods inherited from PostProcessor
postprocessors, registry, #value
Constructor Details
#initialize ⇒ ExcerptPostProcessor
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 |
#regex ⇒ Object
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 |