Class: Yuzu::Filters::PostTitleRemovedFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/yuzu/filters/post_title_removed.rb

Instance Attribute Summary

Attributes inherited from Filter

#directive, #name

Instance Method Summary collapse

Methods inherited from Filter

#filter_type, filters, #get_match, #get_value, #match, #process, registry, #value

Constructor Details

#initializePostTitleRemovedFilter

Returns a new instance of PostTitleRemovedFilter.



5
6
7
8
# File 'lib/yuzu/filters/post_title_removed.rb', line 5

def initialize
  @directive = "POSTTITLEREMOVED"
  @name = :post_title_removed
end

Instance Method Details

#default(website_file) ⇒ Object



10
11
12
# File 'lib/yuzu/filters/post_title_removed.rb', line 10

def default(website_file)
  ""
end

#regexObject



14
15
16
# File 'lib/yuzu/filters/post_title_removed.rb', line 14

def regex
  /^#\s+.*?\n/
end

#replacement(website_file, processing_contents = nil) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/yuzu/filters/post_title_removed.rb', line 18

def replacement(website_file, processing_contents=nil)
  if website_file.config.remove_h1_tags
    ""
  else
    processing_contents.match(regex)
  end
end