Class: BrandEins::Pages::Article
- Inherits:
-
Object
- Object
- BrandEins::Pages::Article
- Defined in:
- lib/brandeins/pages/article.rb
Overview
Represents an article of a magazine
Instance Method Summary collapse
- #brandeins_url ⇒ Object
- #document ⇒ Object
-
#initialize(html) ⇒ Article
constructor
A new instance of Article.
- #pdf_url ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(html) ⇒ Article
Returns a new instance of Article.
12 13 14 |
# File 'lib/brandeins/pages/article.rb', line 12 def initialize(html) @html = html end |
Instance Method Details
#brandeins_url ⇒ Object
32 33 34 |
# File 'lib/brandeins/pages/article.rb', line 32 def brandeins_url BrandEins::Config['base_uri'] end |
#document ⇒ Object
28 29 30 |
# File 'lib/brandeins/pages/article.rb', line 28 def document @document ||= Nokogiri::HTML(@html) end |
#pdf_url ⇒ Object
16 17 18 19 20 |
# File 'lib/brandeins/pages/article.rb', line 16 def pdf_url if node = document.css('a[href$=pdf]').first brandeins_url + '/' + node['href'] end end |
#title ⇒ Object
22 23 24 25 26 |
# File 'lib/brandeins/pages/article.rb', line 22 def title if node = document.css('h2.csc-firstHeader').first node.children.first.text.gsub("\n", '') end end |