Class: IMDB::Page::BasicPage

Inherits:
Object
  • Object
show all
Defined in:
lib/imdb-html/page/basic_page.rb

Class Method Summary collapse

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

.endObject



53
54
55
# File 'lib/imdb-html/page/basic_page.rb', line 53

def self.end
  @@save_file.close
end


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


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_fileObject



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

#nokoObject



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