Class: Fbref::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/webget-football/fbref/page.rb,
lib/webget-football/fbref/page_schedule.rb

Direct Known Subclasses

Schedule

Defined Under Namespace

Classes: Schedule

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Page

Returns a new instance of Page.



16
17
18
# File 'lib/webget-football/fbref/page.rb', line 16

def initialize( html )
  @html = html
end

Class Method Details

.from_cache(url) ⇒ Object



5
6
7
8
# File 'lib/webget-football/fbref/page.rb', line 5

def self.from_cache( url )
  html = Webcache.read( url )
  new( html )
end

.from_file(path) ⇒ Object



10
11
12
13
# File 'lib/webget-football/fbref/page.rb', line 10

def self.from_file( path )
  html = File.open( path, 'r:utf-8' ) {|f| f.read }
  new( html )
end

Instance Method Details

#docObject



20
21
22
23
# File 'lib/webget-football/fbref/page.rb', line 20

def doc
  ## note: if we use a fragment and NOT a document - no access to page head (and meta elements and such)
  @doc ||= Nokogiri::HTML( @html )
end

#titleObject



25
26
27
28
29
# File 'lib/webget-football/fbref/page.rb', line 25

def title
 # <title>Bundesliga 2010/2011 &raquo; Spielplan</title>
   @title ||= doc.css( 'title' ).first
   @title.text  ## get element's text content
end