Module: EndiFeed::Util
- Included in:
- News
- Defined in:
- lib/endi_feed/util.rb
Overview
This module contains various useful functions.
Class Method Summary collapse
-
.convert_date(date) ⇒ String
Converts HTTP-date (RFC 2616) into a simpler date format.
-
.convert_time(date) ⇒ String
Converts HTTP-date (RFC 2616) into the 12-hour format.
- .included(base) ⇒ Object
-
.parse_feed(url = 'http://www.elnuevodia.com/rss/noticias.xml') ⇒ RSS
Fetches and parses RSS feed.
Class Method Details
.convert_date(date) ⇒ String
Converts HTTP-date (RFC 2616) into a simpler date format
27 28 29 30 |
# File 'lib/endi_feed/util.rb', line 27 def convert_date(date) date = String(date) Time.parse(date).strftime('%x') end |
.convert_time(date) ⇒ String
Converts HTTP-date (RFC 2616) into the 12-hour format
35 36 37 38 |
# File 'lib/endi_feed/util.rb', line 35 def convert_time(date) date = String(date) Time.parse(date).strftime('%r') end |
.included(base) ⇒ Object
9 10 11 |
# File 'lib/endi_feed/util.rb', line 9 def self.included(base) base.extend self end |
.parse_feed(url = 'http://www.elnuevodia.com/rss/noticias.xml') ⇒ RSS
Fetches and parses RSS feed
18 19 20 21 22 |
# File 'lib/endi_feed/util.rb', line 18 def parse_feed(url = 'http://www.elnuevodia.com/rss/noticias.xml') open(url) do |rss| RSS::Parser.parse(rss) end end |