Class: Fbref::Page
- Inherits:
-
Object
- Object
- Fbref::Page
- Defined in:
- lib/webget-football/fbref/page.rb,
lib/webget-football/fbref/page_schedule.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Schedule
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(html) ⇒ Page
constructor
A new instance of Page.
- #title ⇒ Object
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
#doc ⇒ Object
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 |
#title ⇒ Object
25 26 27 28 29 |
# File 'lib/webget-football/fbref/page.rb', line 25 def title # <title>Bundesliga 2010/2011 » Spielplan</title> @title ||= doc.css( 'title' ).first @title.text ## get element's text content end |