Class: Mako::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/mako/feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#articlesObject

Returns the value of attribute articles.



5
6
7
# File 'lib/mako/feed.rb', line 5

def articles
  @articles
end

#feed_urlObject

Returns the value of attribute feed_url.



5
6
7
# File 'lib/mako/feed.rb', line 5

def feed_url
  @feed_url
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/mako/feed.rb', line 5

def title
  @title
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/mako/feed.rb', line 5

def url
  @url
end

Instance Method Details

#articles_ascArray

Returns the articles array sorted by date published ascending (oldest first).

Returns:

  • (Array)


17
18
19
# File 'lib/mako/feed.rb', line 17

def articles_asc
  articles.sort_by(&:published)
end

#articles_descArray

Returns the articles array sorted by date published descending (newest first).

Returns:

  • (Array)


25
26
27
# File 'lib/mako/feed.rb', line 25

def articles_desc
  articles_asc.reverse
end