odeon_uk 3.0.6 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -3
- data/CHANGELOG.md +14 -0
- data/{LICENSE.txt → COMM-LICENSE} +0 -0
- data/LICENSE +617 -0
- data/README.md +58 -29
- data/Rakefile +7 -21
- data/lib/odeon_uk.rb +5 -14
- data/lib/odeon_uk/cinema.rb +123 -75
- data/lib/odeon_uk/{api/response.rb → internal/api_response.rb} +3 -3
- data/lib/odeon_uk/internal/parser/api/film_lookup.rb +34 -0
- data/lib/odeon_uk/internal/parser/api/performance_day.rb +92 -0
- data/lib/odeon_uk/internal/title_sanitizer.rb +34 -39
- data/lib/odeon_uk/performance.rb +87 -0
- data/lib/odeon_uk/version.rb +2 -2
- data/odeon_uk.gemspec +19 -21
- data/rake/fixture_creator.rb +5 -57
- data/test/fixtures/api/all_cinemas.plist +0 -0
- data/test/fixtures/api/app_init.plist +0 -0
- data/test/fixtures/api/film_times/71-14876.plist +0 -0
- data/test/fixtures/api/film_times/71-15408.plist +0 -0
- data/test/fixtures/api/film_times/71-15684.plist +0 -0
- data/test/fixtures/api/film_times/71-15866.plist +0 -0
- data/test/fixtures/api/film_times/71-15868.plist +0 -0
- data/test/fixtures/api/film_times/71-15961.plist +0 -0
- data/test/fixtures/api/film_times/71-15963.plist +0 -0
- data/test/fixtures/api/film_times/71-15965.plist +0 -0
- data/test/fixtures/api/film_times/71-15967.plist +0 -0
- data/test/fixtures/api/film_times/71-15969.plist +0 -0
- data/test/fixtures/api/film_times/71-15977.plist +0 -0
- data/test/fixtures/api/film_times/71-15980.plist +0 -0
- data/test/fixtures/api/film_times/71-16037.plist +0 -0
- data/test/fixtures/api/film_times/71-16136.plist +0 -0
- data/test/fixtures/api/film_times/71-16142.plist +0 -0
- data/test/fixtures/api/film_times/71-16143.plist +0 -0
- data/test/fixtures/api/film_times/71-16187.plist +0 -0
- data/test/fixtures/api/film_times/71-16369.plist +0 -0
- data/test/fixtures/api/film_times/71-16370.plist +0 -0
- data/test/fixtures/api/film_times/71-16374.plist +0 -0
- data/test/fixtures/api/film_times/71-16386.plist +0 -0
- data/test/fixtures/api/film_times/71-16387.plist +0 -0
- data/test/fixtures/api/film_times/71-16388.plist +0 -0
- data/test/fixtures/api/film_times/71-16438.plist +0 -0
- data/test/fixtures/api/film_times/71-16454.plist +0 -0
- data/test/fixtures/api/film_times/71-16457.plist +0 -0
- data/test/fixtures/api/film_times/71-16477.plist +0 -0
- data/test/fixtures/api/film_times/71-16478.plist +0 -0
- data/test/fixtures/api/film_times/71-16480.plist +0 -0
- data/test/fixtures/api/film_times/71-16482.plist +0 -0
- data/test/fixtures/api/film_times/71-16489.plist +0 -0
- data/test/lib/odeon_uk/cinema_test.rb +154 -373
- data/test/lib/odeon_uk/{api/response_test.rb → internal/api_response_test.rb} +7 -4
- data/test/lib/odeon_uk/performance_test.rb +149 -0
- data/test/lib/odeon_uk/version_test.rb +3 -5
- data/test/support/api_fixtures_helper.rb +9 -3
- data/test/support/fake_api_response.rb +17 -0
- data/test/test_helper.rb +9 -3
- metadata +89 -145
- data/.rdoc_options +0 -16
- data/lib/odeon_uk/api/cinema.rb +0 -67
- data/lib/odeon_uk/api/screenings.rb +0 -103
- data/lib/odeon_uk/configuration.rb +0 -21
- data/lib/odeon_uk/html/cinema.rb +0 -101
- data/lib/odeon_uk/html/parser/film_with_screenings.rb +0 -160
- data/lib/odeon_uk/html/screenings.rb +0 -38
- data/lib/odeon_uk/html/website.rb +0 -38
- data/lib/odeon_uk/screening.rb +0 -71
- data/test/fixtures/api/film_times/71-100747.plist +0 -0
- data/test/fixtures/api/film_times/71-100750.plist +0 -0
- data/test/fixtures/api/film_times/71-100790.plist +0 -0
- data/test/fixtures/api/film_times/71-14646.plist +0 -0
- data/test/fixtures/api/film_times/71-14725.plist +0 -0
- data/test/fixtures/api/film_times/71-15086.plist +0 -0
- data/test/fixtures/api/film_times/71-15096.plist +0 -0
- data/test/fixtures/api/film_times/71-15122.plist +0 -0
- data/test/fixtures/api/film_times/71-15130.plist +0 -0
- data/test/fixtures/api/film_times/71-15141.plist +0 -0
- data/test/fixtures/api/film_times/71-15142.plist +0 -0
- data/test/fixtures/api/film_times/71-15143.plist +0 -0
- data/test/fixtures/api/film_times/71-15144.plist +0 -0
- data/test/fixtures/api/film_times/71-15145.plist +0 -0
- data/test/fixtures/api/film_times/71-15170.plist +0 -0
- data/test/fixtures/api/film_times/71-15172.plist +0 -0
- data/test/fixtures/api/film_times/71-15177.plist +0 -0
- data/test/fixtures/api/film_times/71-15179.plist +0 -0
- data/test/fixtures/api/film_times/71-15182.plist +0 -0
- data/test/fixtures/api/film_times/71-15286.plist +0 -0
- data/test/fixtures/api/film_times/71-15360.plist +0 -0
- data/test/fixtures/api/film_times/71-15586.plist +0 -0
- data/test/fixtures/api/film_times/71-15700.plist +0 -0
- data/test/fixtures/api/film_times/71-15718.plist +0 -0
- data/test/fixtures/api/film_times/71-15768.plist +0 -0
- data/test/fixtures/api/film_times/71-15788.plist +0 -0
- data/test/fixtures/api/film_times/71-15793.plist +0 -0
- data/test/fixtures/api/film_times/71-15794.plist +0 -0
- data/test/fixtures/api/film_times/71-15795.plist +0 -0
- data/test/fixtures/api/film_times/71-15796.plist +0 -0
- data/test/fixtures/api/film_times/71-15799.plist +0 -0
- data/test/fixtures/api/film_times/71-15802.plist +0 -0
- data/test/fixtures/api/film_times/71-15814.plist +0 -0
- data/test/fixtures/api/film_times/71-15817.plist +0 -0
- data/test/fixtures/api/film_times/71-15840.plist +0 -0
- data/test/fixtures/html/cinema/105.html +0 -2622
- data/test/fixtures/html/cinema/211.html +0 -3241
- data/test/fixtures/html/cinema/71.html +0 -3448
- data/test/fixtures/html/showtimes/11-imax.html +0 -170
- data/test/fixtures/html/showtimes/171-d-box.html +0 -203
- data/test/fixtures/html/showtimes/71-0.html +0 -59
- data/test/fixtures/html/showtimes/71.html +0 -2395
- data/test/fixtures/html/sitemap.html +0 -1303
- data/test/lib/odeon_uk/api/cinema_test.rb +0 -165
- data/test/lib/odeon_uk/api/screenings_test.rb +0 -58
- data/test/lib/odeon_uk/configuration_test.rb +0 -29
- data/test/lib/odeon_uk/html/cinema_test.rb +0 -149
- data/test/lib/odeon_uk/html/parser/film_with_screenings_test.rb +0 -97
- data/test/lib/odeon_uk/html/screenings_test.rb +0 -44
- data/test/lib/odeon_uk/html/website_test.rb +0 -67
- data/test/lib/odeon_uk/screening_test.rb +0 -92
- data/test/support/website_fixtures_helper.rb +0 -30
data/README.md
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
A simple gem to parse the [Odeon UK website](http://odeon.co.uk) and spit out useful formatted info.
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/odeon_uk.
|
6
|
-
[![Code Climate](https://codeclimate.com/github/andycroll/odeon_uk.
|
7
|
-
[![
|
8
|
-
[![
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/odeon_uk.svg)](https://badge.fury.io/rb/odeon_uk)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/andycroll/odeon_uk/badges/gpa.svg)](https://codeclimate.com/github/andycroll/odeon_uk)
|
7
|
+
[![Test Coverage](https://codeclimate.com/github/andycroll/odeon_uk/badges/coverage.svg)](https://codeclimate.com/github/andycroll/odeon_uk/coverage)
|
8
|
+
[![Build Status](https://travis-ci.org/andycroll/odeon_uk.svg?branch=master)](https://travis-ci.org/andycroll/odeon_uk)
|
9
|
+
[![Inline docs](http://inch-ci.org/github/andycroll/odeon_uk.svg?branch=master)](http://inch-ci.org/github/andycroll/odeon_uk)
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -23,48 +24,74 @@ Or install it yourself as:
|
|
23
24
|
|
24
25
|
## Usage
|
25
26
|
|
27
|
+
The gem conforms to the API set down in the `cinebase` gem, [andycroll/cinebase](https://github.com/andycroll/cinebase), which provides a lot of useful base vocabulary and repetitive code for this series of cinema focussed gems.
|
28
|
+
|
29
|
+
Performance titles are sanitized as much as possible, removing 'screening type' information and 'dimension' as well as standardising all the theatre/cultural event naming (NT Live, Royal Opera House etc).
|
30
|
+
|
26
31
|
### Cinema
|
27
32
|
|
28
33
|
``` ruby
|
29
34
|
OdeonUk::Cinema.all
|
30
|
-
#=> [<OdeonUk::Cinema
|
35
|
+
#=> [<OdeonUk::Cinema ...>, <OdeonUk::Cinema ...>, ...]
|
31
36
|
|
32
|
-
OdeonUk::Cinema.
|
33
|
-
#=> <OdeonUk::Cinema
|
37
|
+
cinema = OdeonUk::Cinema.new(71)
|
38
|
+
#=> <OdeonUk::Cinema ...>
|
34
39
|
|
35
|
-
|
36
|
-
#=>
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
cinema.adr
|
41
|
+
#=> {
|
42
|
+
street_address: 'Kingswest',
|
43
|
+
extended_address: nil,
|
44
|
+
locality: 'Brighton',
|
45
|
+
region: nil,
|
46
|
+
postal_code: 'BN1 2RE',
|
47
|
+
country: 'United Kingdom'
|
48
|
+
}
|
40
49
|
|
41
50
|
cinema.brand
|
42
51
|
#=> 'Odeon'
|
43
52
|
|
44
|
-
cinema.
|
45
|
-
#=> '
|
53
|
+
cinema.full_name
|
54
|
+
#=> 'Odeon Brighton'
|
46
55
|
|
47
|
-
cinema.
|
48
|
-
#=>
|
56
|
+
cinema.id
|
57
|
+
#=> 71
|
49
58
|
|
50
|
-
cinema.
|
51
|
-
#=>
|
59
|
+
cinema.postal_code
|
60
|
+
#=> 'BN1 2RE'
|
61
|
+
```
|
52
62
|
|
53
|
-
|
54
|
-
#=> [<OdeonUk::Screening film="About Time" when="2013-09-09 11:00 UTC" variant="3d">, <OdeonUk::Screening film="Iron Man 3" when="2013-09-09 13:50 UTC" variant="kids">, <OdeonUk::Screening ..>, <OdeonUk::Screening ...>]
|
63
|
+
### Performances
|
55
64
|
|
56
|
-
|
57
|
-
|
65
|
+
``` ruby
|
66
|
+
OdeonUk::Performance.at(17)
|
67
|
+
#=> [<OdeonUk::Performance ...>, <OdeonUk::Performance ...>, ...]
|
58
68
|
|
59
|
-
|
60
|
-
#=>
|
61
|
-
```
|
69
|
+
performance = OdeonUk::Performance.at(17).first
|
70
|
+
#=> <OdeonUk::Performance ...>
|
62
71
|
|
63
|
-
|
72
|
+
performance.film_name
|
73
|
+
#=> 'Star Wars: The Force Awakens'
|
64
74
|
|
65
|
-
|
66
|
-
|
67
|
-
|
75
|
+
performance.dimension
|
76
|
+
#=> '2d'
|
77
|
+
|
78
|
+
performance.variant
|
79
|
+
#=> ['imax', 'kids']
|
80
|
+
|
81
|
+
performance.starting_at
|
82
|
+
#=> 2016-02-04 13:00:00 UTC
|
83
|
+
|
84
|
+
performance.showing_on
|
85
|
+
#=> #<Date: 2016-02-04 ((2457423j,0s,0n),+0s,2299161j)>
|
86
|
+
|
87
|
+
performance.booking_url # for now
|
88
|
+
#=> nil
|
89
|
+
|
90
|
+
performance.cinema_name
|
91
|
+
#=> 'Brighton'
|
92
|
+
|
93
|
+
performance.cinema_id
|
94
|
+
#=> 71
|
68
95
|
```
|
69
96
|
|
70
97
|
## Contributing
|
@@ -74,3 +101,5 @@ OdeonUk::Film.all
|
|
74
101
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
75
102
|
4. Push to the branch (`git push origin my-new-feature`)
|
76
103
|
5. Create new Pull Request
|
104
|
+
|
105
|
+
Note that contributors assign all rights to the owner, Andy Croll ([github](http://github.com/andycroll)), of this gem.
|
data/Rakefile
CHANGED
@@ -8,8 +8,6 @@ Rake::TestTask.new do |t|
|
|
8
8
|
t.test_files = FileList[
|
9
9
|
'test/lib/odeon_uk/*_test.rb',
|
10
10
|
'test/lib/odeon_uk/api/*_test.rb',
|
11
|
-
'test/lib/odeon_uk/html/*_test.rb',
|
12
|
-
'test/lib/odeon_uk/html/parser/*_test.rb',
|
13
11
|
'test/lib/odeon_uk/internal/*_test.rb'
|
14
12
|
]
|
15
13
|
t.verbose = true
|
@@ -26,28 +24,16 @@ task :console do
|
|
26
24
|
end
|
27
25
|
|
28
26
|
desc 'recreate test fixtures'
|
29
|
-
|
27
|
+
task :fixtures do
|
30
28
|
require 'odeon_uk'
|
31
29
|
require_relative 'rake/fixture_creator'
|
30
|
+
require 'fileutils'
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
FixtureCreator::Html.new(105).cinema! # leceister square
|
39
|
-
FixtureCreator::Html.new(71).showtimes!
|
40
|
-
FixtureCreator::Html.new(71).film_node!(0)
|
41
|
-
FixtureCreator::Html.new(11).film_node!('imax') # manchester imax
|
42
|
-
FixtureCreator::Html.new(171).film_node!('d-box') # liverpool dbox
|
43
|
-
end
|
44
|
-
|
45
|
-
desc 'api'
|
46
|
-
task :api do
|
47
|
-
FixtureCreator::Api.new.app_init!
|
48
|
-
FixtureCreator::Api.new.all_cinemas!
|
49
|
-
FixtureCreator::Api.new.film_times!(71)
|
50
|
-
end
|
32
|
+
FixtureCreator::Api.new.app_init!
|
33
|
+
FixtureCreator::Api.new.all_cinemas!
|
34
|
+
puts 'Clean folder'
|
35
|
+
FileUtils.rm FileList['test/fixtures/api/film_times/*.plist']
|
36
|
+
FixtureCreator::Api.new.film_times!(71)
|
51
37
|
end
|
52
38
|
|
53
39
|
task default: :test
|
data/lib/odeon_uk.rb
CHANGED
@@ -1,24 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'tzinfo'
|
4
|
-
require 'tzinfo/data'
|
1
|
+
require 'cinebase'
|
5
2
|
|
6
3
|
require_relative './odeon_uk/version'
|
7
|
-
require_relative './odeon_uk/configuration'
|
8
4
|
|
5
|
+
require_relative './odeon_uk/internal/api_response'
|
9
6
|
require_relative './odeon_uk/internal/title_sanitizer'
|
10
7
|
|
11
|
-
require_relative './odeon_uk/api/
|
12
|
-
require_relative './odeon_uk/api/
|
13
|
-
require_relative './odeon_uk/api/screenings'
|
14
|
-
|
15
|
-
require_relative './odeon_uk/html/parser/film_with_screenings'
|
16
|
-
require_relative './odeon_uk/html/website'
|
17
|
-
require_relative './odeon_uk/html/cinema'
|
18
|
-
require_relative './odeon_uk/html/screenings'
|
8
|
+
require_relative './odeon_uk/internal/parser/api/film_lookup'
|
9
|
+
require_relative './odeon_uk/internal/parser/api/performance_day'
|
19
10
|
|
20
11
|
require_relative './odeon_uk/cinema'
|
21
|
-
require_relative './odeon_uk/
|
12
|
+
require_relative './odeon_uk/performance'
|
22
13
|
|
23
14
|
# odeon_uk gem
|
24
15
|
module OdeonUk
|
data/lib/odeon_uk/cinema.rb
CHANGED
@@ -1,115 +1,163 @@
|
|
1
1
|
module OdeonUk
|
2
2
|
# The object representing a cinema on the Odeon UK website
|
3
|
-
class Cinema
|
4
|
-
|
5
|
-
|
6
|
-
# @return [Integer] the numeric id of the cinema on the Odeon website
|
7
|
-
attr_reader :id
|
8
|
-
|
9
|
-
# @!method locality
|
10
|
-
# The locality (town) of the cinema
|
11
|
-
# @return [String]
|
12
|
-
# @example
|
13
|
-
# cinema = OdeonUk::Cinema.find('71')
|
14
|
-
# cinema.locality
|
15
|
-
# #=> 'Brighton'
|
16
|
-
# @!method postal_code
|
17
|
-
# Post code of the cinema
|
18
|
-
# @return [String]
|
19
|
-
# @example
|
20
|
-
# cinema = OdeonUk::Cinema.find('71')
|
21
|
-
# cinema.postal_code
|
22
|
-
# #=> 'BN1 2RE'
|
23
|
-
# @!method street_address
|
24
|
-
# The street adress of the cinema
|
25
|
-
# @return [String]
|
26
|
-
# @example
|
27
|
-
# cinema = OdeonUk::Cinema.find('71')
|
28
|
-
# cinema.street_address
|
29
|
-
# #=> 'Kingswest'
|
30
|
-
# @!method url
|
31
|
-
# Website URI for the cinema
|
32
|
-
# @return [String] the url of the cinema on the Odeon website
|
33
|
-
def_delegators :cinema_parser, :locality, :postal_code, :street_address,
|
34
|
-
:url
|
3
|
+
class Cinema < Cinebase::Cinema
|
4
|
+
# @!attribute [r] id
|
5
|
+
# @return [Integer] the numeric id of the cinema on the Cineworld website
|
35
6
|
|
7
|
+
# Constructor
|
36
8
|
# @param [Integer, String] id the cinema id of the format 71/'71' as used on
|
37
|
-
# the odeon.co.uk website
|
38
9
|
# @return [OdeonUk::Cinema]
|
39
10
|
def initialize(id)
|
40
|
-
@id = id
|
11
|
+
@id = id.to_s
|
41
12
|
end
|
42
13
|
|
43
14
|
# Return basic cinema information for all cinemas
|
44
15
|
# @return [Array<OdeonUk::Cinema>]
|
16
|
+
# @example
|
17
|
+
# OdeonUk::Cinema.all
|
18
|
+
# #=> [<OdeonUk::Cinema>, <OdeonUk::Cinema>, ...]
|
45
19
|
def self.all
|
46
|
-
|
20
|
+
cinemas_hash.keys.map { |cinema_id| new(cinema_id) }
|
47
21
|
end
|
48
22
|
|
23
|
+
# @!method address
|
24
|
+
# Address of the cinema
|
25
|
+
# @return [Hash] of different address parts
|
26
|
+
# @see #adr
|
27
|
+
|
49
28
|
# Address of the cinema
|
50
|
-
# @return [Hash]
|
29
|
+
# @return [Hash] contains :street_address, :extended_address,
|
30
|
+
# :locality, :postal_code, :country
|
51
31
|
# @example
|
52
|
-
# cinema = OdeonUk::Cinema.
|
32
|
+
# cinema = OdeonUk::Cinema.new(3)
|
53
33
|
# cinema.adr
|
54
|
-
# #=> {
|
34
|
+
# #=> {
|
35
|
+
# street_address: '44-47 Gardner Street',
|
36
|
+
# extended_address: 'North Laine',
|
55
37
|
# locality: 'Brighton',
|
56
|
-
# postal_code: 'BN1
|
57
|
-
# country_name: 'United Kingdom'
|
38
|
+
# postal_code: 'BN1 1UN',
|
39
|
+
# country_name: 'United Kingdom'
|
40
|
+
# }
|
41
|
+
# @note Uses the standard method naming as at http://microformats.org/wiki/adr
|
58
42
|
def adr
|
59
43
|
{
|
60
|
-
street_address:
|
61
|
-
|
62
|
-
|
63
|
-
|
44
|
+
street_address: cinema_hash['siteAddress1'],
|
45
|
+
extended_address: nil,
|
46
|
+
locality: cinema_hash['siteAddress2'],
|
47
|
+
region: nil,
|
48
|
+
postal_code: cinema_hash['sitePostcode'],
|
49
|
+
country_name: 'United Kingdom'.freeze
|
64
50
|
}
|
65
51
|
end
|
66
|
-
alias_method :address, :adr
|
67
52
|
|
68
|
-
#
|
53
|
+
# Brand of the cinema
|
54
|
+
# @return [String] which will always be 'Odeon'
|
55
|
+
# @example
|
56
|
+
# cinema = OdeonUk::Cinema.new(3)
|
57
|
+
# cinema.brand
|
58
|
+
# #=> 'Cineworld'
|
69
59
|
def brand
|
70
|
-
'Odeon'
|
60
|
+
'Odeon'.freeze
|
71
61
|
end
|
72
62
|
|
73
|
-
#
|
63
|
+
# @!method country_name
|
64
|
+
# Country of the cinema
|
65
|
+
# @return [String] which will always be 'United Kingdom'
|
66
|
+
# @example
|
67
|
+
# cinema = CineworldUk::Cinema.new(3)
|
68
|
+
# cinema.country_name
|
69
|
+
# #=> 'United Kingdom'
|
70
|
+
|
71
|
+
# @!method extended_address
|
72
|
+
# The second address line of the cinema
|
73
|
+
# @return [String]
|
74
|
+
# @example
|
75
|
+
# cinema = CineworldUk::Cinema.new(10)
|
76
|
+
# cinema.extended_address
|
77
|
+
# #=> 'Chelsea'
|
78
|
+
#
|
79
|
+
# cinema = CineworldUk::Cinema.new(3)
|
80
|
+
# cinema.extended_address
|
81
|
+
# #=> ''
|
82
|
+
|
83
|
+
# @!method full_name
|
84
|
+
# The name of the cinema including the brand
|
85
|
+
# @return [String]
|
86
|
+
# @example
|
87
|
+
# cinema = CineworldUk::Cinema.new(88)
|
88
|
+
# cinema.full_name
|
89
|
+
# #=> 'Cineworld Glasgow: IMAX at GSC'
|
90
|
+
|
91
|
+
# @!method locality
|
92
|
+
# The locality (town) of the cinema
|
93
|
+
# @return [String]
|
94
|
+
# @example
|
95
|
+
# cinema = CineworldUk::Cinema.new(3)
|
96
|
+
# cinema.locality
|
97
|
+
# #=> 'Brighton'
|
98
|
+
|
99
|
+
# The name of the cinema
|
74
100
|
# @return [String]
|
75
101
|
# @example
|
76
|
-
# cinema =
|
77
|
-
# cinema.
|
78
|
-
# #=> '
|
79
|
-
def full_name
|
80
|
-
@full_name ||= "#{brand} #{name}"
|
81
|
-
end
|
82
|
-
|
83
|
-
# Cinema name, slightly sanitized
|
84
|
-
# @return [String] the name of the cinema
|
102
|
+
# cinema = CineworldUk::Cinema.new(3)
|
103
|
+
# cinema.name
|
104
|
+
# #=> 'Brighton'
|
85
105
|
def name
|
86
|
-
@name ||=
|
106
|
+
@name ||= cinema_hash['siteName'].gsub(/\ALondon /, '').gsub(' - ', ': ')
|
87
107
|
end
|
88
108
|
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
96
|
-
Screening.at(id)
|
97
|
-
end
|
109
|
+
# @!method postal_code
|
110
|
+
# Post code of the cinema
|
111
|
+
# @return [String]
|
112
|
+
# @example
|
113
|
+
# cinema = CineworldUk::Cinema.new(3)
|
114
|
+
# cinema.postal_code
|
115
|
+
# #=> 'BN2 5UF'
|
98
116
|
|
99
|
-
#
|
100
|
-
#
|
101
|
-
|
102
|
-
|
117
|
+
# @!method region
|
118
|
+
# The region (county) of the cinema if provided
|
119
|
+
# @return [String]
|
120
|
+
# @example
|
121
|
+
# cinema = CineworldUk::Cinema.new(3)
|
122
|
+
# cinema.region
|
123
|
+
# #=> 'East Sussex'
|
124
|
+
|
125
|
+
# @!method slug
|
126
|
+
# The URL-able slug of the cinema
|
127
|
+
# @return [String]
|
128
|
+
# @example
|
129
|
+
# cinema = CineworldUk::Cinema.new(3)
|
130
|
+
# cinema.slug
|
131
|
+
# #=> 'odeon-brighton'
|
132
|
+
|
133
|
+
# @!method street_address
|
134
|
+
# The street address of the cinema
|
135
|
+
# @return [String]
|
136
|
+
# @example
|
137
|
+
# cinema = CineworldUk::Cinema.new(3)
|
138
|
+
# cinema.street_address
|
139
|
+
# #=> 'Brighton Marina'
|
140
|
+
# @note Uses the standard method naming as at http://microformats.org/wiki/adr
|
141
|
+
|
142
|
+
# The url of the cinema on the Cineworld website
|
143
|
+
# @return [String]
|
144
|
+
def url
|
145
|
+
"http://www.odeon.co.uk/cinemas/#{urlized_name}/#{id}/"
|
103
146
|
end
|
104
147
|
|
105
148
|
private
|
106
149
|
|
107
|
-
def self.
|
108
|
-
|
150
|
+
def self.cinemas_hash
|
151
|
+
@cinemas_hash ||=
|
152
|
+
OdeonUk::Internal::ApiResponse.new.all_cinemas.fetch('sites', {})
|
153
|
+
end
|
154
|
+
|
155
|
+
def cinema_hash
|
156
|
+
@cinema_hash ||= self.class.cinemas_hash.fetch(id, {})
|
109
157
|
end
|
110
158
|
|
111
|
-
def
|
112
|
-
|
159
|
+
def urlized_name
|
160
|
+
name.downcase.gsub(/[^a-z0-9]/, '_')
|
113
161
|
end
|
114
162
|
end
|
115
163
|
end
|
@@ -4,11 +4,11 @@ require 'net/http'
|
|
4
4
|
module OdeonUk
|
5
5
|
# Internal utility classes: Do not use
|
6
6
|
# @api private
|
7
|
-
module
|
7
|
+
module Internal
|
8
8
|
# Utility class to make calls to the odeon website
|
9
|
-
class
|
9
|
+
class ApiResponse
|
10
10
|
# iOS app API version
|
11
|
-
VERSION = '2.1'
|
11
|
+
VERSION = '2.1'.freeze
|
12
12
|
|
13
13
|
# cinemas information
|
14
14
|
# @return [Hash] decoded response of api containing cinema details
|