Class: Newly::News

Inherits:
Object
  • Object
show all
Defined in:
lib/newly/news.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ News

Returns a new instance of News.



5
6
7
8
9
10
11
12
13
14
# File 'lib/newly/news.rb', line 5

def initialize(args)
  page_crawler = args[:page_crawler]
  feed = args[:feed]

  @feed_url = args[:feed_url]
  @url = page_crawler.link feed.url_pattern
  @title = page_crawler.titleize feed.title
  @subtitle = page_crawler.titleize feed.subtitle
  @image = page_crawler.image feed.image_source
end

Instance Attribute Details

#feed_urlObject (readonly)

Returns the value of attribute feed_url.



3
4
5
# File 'lib/newly/news.rb', line 3

def feed_url
  @feed_url
end

#imageObject (readonly)

Returns the value of attribute image.



3
4
5
# File 'lib/newly/news.rb', line 3

def image
  @image
end

#subtitleObject (readonly)

Returns the value of attribute subtitle.



3
4
5
# File 'lib/newly/news.rb', line 3

def subtitle
  @subtitle
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/newly/news.rb', line 3

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/newly/news.rb', line 3

def url
  @url
end

Instance Method Details

#to_hashObject



16
17
18
19
20
21
22
23
24
# File 'lib/newly/news.rb', line 16

def to_hash
  {
    url: @url,
    title: @title,
    subtitle: @subtitle,
    image: @image,
    feed_url: @feed_url
  }
end