Class: IMDB::Page::BasicPage
- Inherits:
-
Object
- Object
- IMDB::Page::BasicPage
- Defined in:
- lib/imdb-html/page/basic_page.rb
Class Method Summary collapse
- .commit(io_path) ⇒ Object
- .end ⇒ Object
- .links(lines) ⇒ Object
- .memoize_links(io_paths) ⇒ Object
- .save_file ⇒ Object
- .stub(stub_str) ⇒ Object
Instance Method Summary collapse
Class Method Details
.commit(io_path) ⇒ Object
49 50 51 |
# File 'lib/imdb-html/page/basic_page.rb', line 49 def self.commit io_path save_file.puts links File.readlines(io_path) end |
.end ⇒ Object
53 54 55 |
# File 'lib/imdb-html/page/basic_page.rb', line 53 def self.end @@save_file.close end |
.links(lines) ⇒ Object
39 40 41 42 43 |
# File 'lib/imdb-html/page/basic_page.rb', line 39 def self.links lines lines.map do |line| line.scan(%r{href=".*?"}) end end |
.memoize_links(io_paths) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/imdb-html/page/basic_page.rb', line 16 def self.memoize_links io_paths io_paths.each_with_index do |path, idx| self.commit(path) print "\b"*(idx.to_s.length) + idx.to_s + "/#{io_paths.count}" end self.end end |
.save_file ⇒ Object
45 46 47 |
# File 'lib/imdb-html/page/basic_page.rb', line 45 def self.save_file @@save_file end |
.stub(stub_str) ⇒ Object
12 13 14 |
# File 'lib/imdb-html/page/basic_page.rb', line 12 def self.stub(stub_str) self.base_uri File.join self.base_uri, stub_str end |
Instance Method Details
#noko ⇒ Object
35 36 37 |
# File 'lib/imdb-html/page/basic_page.rb', line 35 def noko Nokogiri::HTML.parse target end |
#target(raw_html) ⇒ Object
29 30 31 32 33 |
# File 'lib/imdb-html/page/basic_page.rb', line 29 def target raw_html raw_html[ DIV_ID_PAGECONTENT ][ DIV_ID_FOOTER ] .sub(BILLBOARD, "") .gsub(BR, "") end |