Class: BrandEins::Pages::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/brandeins/pages/article.rb

Overview

Represents an article of a magazine

Instance Method Summary collapse

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_urlObject



32
33
34
# File 'lib/brandeins/pages/article.rb', line 32

def brandeins_url
  BrandEins::Config['base_uri']
end

#documentObject



28
29
30
# File 'lib/brandeins/pages/article.rb', line 28

def document
  @document ||= Nokogiri::HTML(@html)
end

#pdf_urlObject



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

#titleObject



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