google_movies 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ module HttpCapture
19
19
  @doc.search('div[@class="theater"]').each do |theater|
20
20
  movies = []
21
21
  movies = get_movies(theater)
22
- @movies_theater << GoogleMovies::MovieTheater.new(theater.search('h2[@class="name"]').first.content, theater.search('div[@class="info"]').first.content, movies)
22
+ @movies_theater << create_movie_theater_with(theater, movies)
23
23
  end
24
24
  @movies_theater
25
25
  end
@@ -29,11 +29,24 @@ module HttpCapture
29
29
  def page_doc(uri)
30
30
  Nokogiri::HTML(Net::HTTP.get_response(uri).body)
31
31
  end
32
+
33
+ def create_movie_theater_with(theater, movies)
34
+ id = theater.search('div[@class="desc"]').first.attr("id").gsub("theater_", "")
35
+ name = theater.search('h2[@class="name"]').first.content
36
+ info = theater.search('div[@class="info"]').first.content
37
+ GoogleMovies::MovieTheater.new(name, info, id, movies)
38
+ end
39
+
40
+ def create_movie_with(movie)
41
+ name = movie.search('div[@class="name"]').first.search('a').first.content
42
+ id = movie.search('div[@class="name"]').first.search('a').first.attr("href").split("&mid=")[1]
43
+ GoogleMovies::Movie.new(name, id)
44
+ end
32
45
 
33
46
  def get_movies(theater)
34
47
  movies = []
35
- theater.search('div[@class="movie"]').each do |movie|
36
- movies << GoogleMovies::Movie.new(movie.search('div[@class="name"]').first.search('a').first.content)
48
+ theater.search('div[@class="movie"]').each do |movie_document|
49
+ movies << create_movie_with(movie_document)
37
50
  end
38
51
  movies
39
52
  end
@@ -1,10 +1,11 @@
1
1
  module GoogleMovies
2
2
  class Movie
3
3
 
4
- attr_accessor :name
4
+ attr_accessor :name, :id
5
5
 
6
- def initialize(name)
6
+ def initialize(name, id)
7
7
  @name = name
8
+ @id = id
8
9
  end
9
10
  end
10
11
  end
@@ -1,12 +1,13 @@
1
1
  module GoogleMovies
2
2
  class MovieTheater
3
3
 
4
- attr_accessor :movies, :name, :address
4
+ attr_accessor :movies, :name, :address, :id
5
5
 
6
- def initialize(name, address, movies = [])
6
+ def initialize(name, address, id, movies = [])
7
7
  @movies = movies
8
8
  @name = name
9
9
  @address = address
10
+ @id = id
10
11
  end
11
12
  end
12
13
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleMovies
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/google_movies.rb CHANGED
@@ -8,7 +8,7 @@ module GoogleMovies
8
8
 
9
9
  class Client
10
10
 
11
- ROOT_URL = "http://www.google.com/movies"
11
+ ROOT_URL = "http://google.com/movies"
12
12
 
13
13
  def initialize(city)
14
14
  @city = city
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_movies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-14 00:00:00.000000000 Z
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 1.8.21
110
+ rubygems_version: 1.8.22
111
111
  signing_key:
112
112
  specification_version: 3
113
113
  summary: Ruby wrapper to access google movies informations