Class: Yuzu::Filters::CategoriesFilter
Instance Attribute Summary
Attributes inherited from Filter
#directive, #name
Instance Method Summary
collapse
Methods inherited from Filter
#filter_type, filters, #get_match, #match, #process, #regex, registry, #replacement, #value
Constructor Details
7
8
9
10
|
# File 'lib/yuzu/filters/categories.rb', line 7
def initialize
@name = :categories
@directive = "CATEGORIES"
end
|
Instance Method Details
#default(website_file) ⇒ Object
12
13
14
|
# File 'lib/yuzu/filters/categories.rb', line 12
def default(website_file)
[Category.new("uncategorized", website_file)]
end
|
#get_value(website_file) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/yuzu/filters/categories.rb', line 16
def get_value(website_file)
m = match(website_file.raw_contents)
return default(website_file) if m.nil?
category_list = m.split(",")
category_list.collect! {|cat| cat.strip.downcase}
category_list.reject! {|cat| cat.empty?}
category_list.collect {|cat| Category.new(cat, website_file)}
end
|