Class: Yuzu::Filters::PostDateFilter
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
Returns a new instance of PostDateFilter.
5
6
7
8
|
# File 'lib/yuzu/filters/post_date.rb', line 5
def initialize
@directive = "DATE"
@name = :post_date
end
|
Instance Method Details
#default(website_file) ⇒ Object
10
11
12
|
# File 'lib/yuzu/filters/post_date.rb', line 10
def default(website_file)
website_file.modified_at
end
|
31
32
33
34
35
|
# File 'lib/yuzu/filters/post_date.rb', line 31
def (website_file)
post_filename = website_file.filename
m = post_filename.match(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/)
m.nil? ? nil : Time.parse(m[0])
end
|
37
38
39
40
|
# File 'lib/yuzu/filters/post_date.rb', line 37
def (website_file)
m = website_file.path.relative.match(/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/)
m.nil? ? nil : Time.parse(m[0].gsub("/", "-"))
end
|
#get_value(website_file) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/yuzu/filters/post_date.rb', line 14
def get_value(website_file)
date = match(website_file.raw_contents)
if not date.nil?
begin
date = Time.parse(date)
rescue
date = nil
end
end
date ||= (website_file)
date ||= (website_file)
date ||= default(website_file)
date
end
|