Class: Newly::News
- Inherits:
-
Object
- Object
- Newly::News
- Defined in:
- lib/newly/news.rb
Instance Attribute Summary collapse
-
#feed_url ⇒ Object
readonly
Returns the value of attribute feed_url.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#subtitle ⇒ Object
readonly
Returns the value of attribute subtitle.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(args) ⇒ News
constructor
A new instance of News.
- #to_hash ⇒ Object
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_url ⇒ Object (readonly)
Returns the value of attribute feed_url.
3 4 5 |
# File 'lib/newly/news.rb', line 3 def feed_url @feed_url end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/newly/news.rb', line 3 def image @image end |
#subtitle ⇒ Object (readonly)
Returns the value of attribute subtitle.
3 4 5 |
# File 'lib/newly/news.rb', line 3 def subtitle @subtitle end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/newly/news.rb', line 3 def title @title end |
#url ⇒ Object (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_hash ⇒ Object
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 |