Class: Mako::Feed
- Inherits:
-
Object
- Object
- Mako::Feed
- Defined in:
- lib/mako/feed.rb
Instance Attribute Summary collapse
-
#articles ⇒ Object
Returns the value of attribute articles.
-
#feed_url ⇒ Object
Returns the value of attribute feed_url.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#articles_asc ⇒ Array
Returns the articles array sorted by date published ascending (oldest first).
-
#articles_desc ⇒ Array
Returns the articles array sorted by date published descending (newest first).
-
#initialize(args) ⇒ Feed
constructor
A new instance of Feed.
Constructor Details
#initialize(args) ⇒ Feed
Returns a new instance of Feed.
7 8 9 10 11 |
# File 'lib/mako/feed.rb', line 7 def initialize(args) @url = args.fetch(:url) @title = args.fetch(:title) @articles = [] end |
Instance Attribute Details
#articles ⇒ Object
Returns the value of attribute articles.
5 6 7 |
# File 'lib/mako/feed.rb', line 5 def articles @articles end |
#feed_url ⇒ Object
Returns the value of attribute feed_url.
5 6 7 |
# File 'lib/mako/feed.rb', line 5 def feed_url @feed_url end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/mako/feed.rb', line 5 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/mako/feed.rb', line 5 def url @url end |
Instance Method Details
#articles_asc ⇒ Array
Returns the articles array sorted by date published ascending (oldest first).
17 18 19 |
# File 'lib/mako/feed.rb', line 17 def articles_asc articles.sort_by(&:published) end |
#articles_desc ⇒ Array
Returns the articles array sorted by date published descending (newest first).
25 26 27 |
# File 'lib/mako/feed.rb', line 25 def articles_desc articles_asc.reverse end |