Class: Html2rss::AttributePostProcessors::ParseTime

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/attribute_post_processors/parse_time.rb

Overview

Returns the RFC822 representation of a time.

Imagine this HTML structure:

Published on 2019-07-02

YAML usage example:

selectors:
 description:
   selector: span
   post_process:
     name: 'parse_time'

Would return:

"Tue, 02 Jul 2019 00:00:00 +0200"

It uses Time.parse. As of now it ignores time zones and always falls back to the UTC time zone.

Instance Method Summary collapse

Constructor Details

#initialize(value, env) ⇒ ParseTime

Returns a new instance of ParseTime.



27
28
29
30
# File 'lib/html2rss/attribute_post_processors/parse_time.rb', line 27

def initialize(value, env)
  @value = value.to_s
  @time_zone = env[:config].time_zone
end

Instance Method Details

#get ⇒ String

Returns rfc822 formatted time.

Returns:

  • (String) —

    rfc822 formatted time



34
35
36
# File 'lib/html2rss/attribute_post_processors/parse_time.rb', line 34

def get
  Time.use_zone(@time_zone) { Time.zone.parse(@value).rfc822 }
end