Class: ComicFeed

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

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feed) ⇒ ComicFeed

Returns a new instance of ComicFeed.



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

def initialize(feed)
  first = feed.first

  if first
    first_date = first.posted_at
  else
    first_date = Date.today
  end

  @pub_date = first_date.to_time.strftime "%a, %d %b %Y 00:00:01 %z"
  @items = feed.map do |item|
    ComicFeed::Item.new item
  end
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



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

def items
  @items
end

#pub_dateObject (readonly)

Returns the value of attribute pub_date.



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

def pub_date
  @pub_date
end