Class: BlogFeed

Inherits:
Object
  • Object
show all
Defined in:
app/models/blog_feed.rb

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feed) ⇒ BlogFeed

Returns a new instance of BlogFeed.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/blog_feed.rb', line 4

def initialize(feed)
  first = feed.first

  if first
    first_date = first.posted_at
  else
    first_date = Time.now
  end

  @pub_date = first_date.localtime.strftime "%a, %d %b %Y %H:%M:00 %z"
  @items = feed.map do |item|
    BlogFeed::Item.new item
  end
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



2
3
4
# File 'app/models/blog_feed.rb', line 2

def items
  @items
end

#pub_dateObject (readonly)

Returns the value of attribute pub_date.



2
3
4
# File 'app/models/blog_feed.rb', line 2

def pub_date
  @pub_date
end