odeon_uk 3.0.6 → 4.0.0

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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -3
  3. data/CHANGELOG.md +14 -0
  4. data/{LICENSE.txt → COMM-LICENSE} +0 -0
  5. data/LICENSE +617 -0
  6. data/README.md +58 -29
  7. data/Rakefile +7 -21
  8. data/lib/odeon_uk.rb +5 -14
  9. data/lib/odeon_uk/cinema.rb +123 -75
  10. data/lib/odeon_uk/{api/response.rb → internal/api_response.rb} +3 -3
  11. data/lib/odeon_uk/internal/parser/api/film_lookup.rb +34 -0
  12. data/lib/odeon_uk/internal/parser/api/performance_day.rb +92 -0
  13. data/lib/odeon_uk/internal/title_sanitizer.rb +34 -39
  14. data/lib/odeon_uk/performance.rb +87 -0
  15. data/lib/odeon_uk/version.rb +2 -2
  16. data/odeon_uk.gemspec +19 -21
  17. data/rake/fixture_creator.rb +5 -57
  18. data/test/fixtures/api/all_cinemas.plist +0 -0
  19. data/test/fixtures/api/app_init.plist +0 -0
  20. data/test/fixtures/api/film_times/71-14876.plist +0 -0
  21. data/test/fixtures/api/film_times/71-15408.plist +0 -0
  22. data/test/fixtures/api/film_times/71-15684.plist +0 -0
  23. data/test/fixtures/api/film_times/71-15866.plist +0 -0
  24. data/test/fixtures/api/film_times/71-15868.plist +0 -0
  25. data/test/fixtures/api/film_times/71-15961.plist +0 -0
  26. data/test/fixtures/api/film_times/71-15963.plist +0 -0
  27. data/test/fixtures/api/film_times/71-15965.plist +0 -0
  28. data/test/fixtures/api/film_times/71-15967.plist +0 -0
  29. data/test/fixtures/api/film_times/71-15969.plist +0 -0
  30. data/test/fixtures/api/film_times/71-15977.plist +0 -0
  31. data/test/fixtures/api/film_times/71-15980.plist +0 -0
  32. data/test/fixtures/api/film_times/71-16037.plist +0 -0
  33. data/test/fixtures/api/film_times/71-16136.plist +0 -0
  34. data/test/fixtures/api/film_times/71-16142.plist +0 -0
  35. data/test/fixtures/api/film_times/71-16143.plist +0 -0
  36. data/test/fixtures/api/film_times/71-16187.plist +0 -0
  37. data/test/fixtures/api/film_times/71-16369.plist +0 -0
  38. data/test/fixtures/api/film_times/71-16370.plist +0 -0
  39. data/test/fixtures/api/film_times/71-16374.plist +0 -0
  40. data/test/fixtures/api/film_times/71-16386.plist +0 -0
  41. data/test/fixtures/api/film_times/71-16387.plist +0 -0
  42. data/test/fixtures/api/film_times/71-16388.plist +0 -0
  43. data/test/fixtures/api/film_times/71-16438.plist +0 -0
  44. data/test/fixtures/api/film_times/71-16454.plist +0 -0
  45. data/test/fixtures/api/film_times/71-16457.plist +0 -0
  46. data/test/fixtures/api/film_times/71-16477.plist +0 -0
  47. data/test/fixtures/api/film_times/71-16478.plist +0 -0
  48. data/test/fixtures/api/film_times/71-16480.plist +0 -0
  49. data/test/fixtures/api/film_times/71-16482.plist +0 -0
  50. data/test/fixtures/api/film_times/71-16489.plist +0 -0
  51. data/test/lib/odeon_uk/cinema_test.rb +154 -373
  52. data/test/lib/odeon_uk/{api/response_test.rb → internal/api_response_test.rb} +7 -4
  53. data/test/lib/odeon_uk/performance_test.rb +149 -0
  54. data/test/lib/odeon_uk/version_test.rb +3 -5
  55. data/test/support/api_fixtures_helper.rb +9 -3
  56. data/test/support/fake_api_response.rb +17 -0
  57. data/test/test_helper.rb +9 -3
  58. metadata +89 -145
  59. data/.rdoc_options +0 -16
  60. data/lib/odeon_uk/api/cinema.rb +0 -67
  61. data/lib/odeon_uk/api/screenings.rb +0 -103
  62. data/lib/odeon_uk/configuration.rb +0 -21
  63. data/lib/odeon_uk/html/cinema.rb +0 -101
  64. data/lib/odeon_uk/html/parser/film_with_screenings.rb +0 -160
  65. data/lib/odeon_uk/html/screenings.rb +0 -38
  66. data/lib/odeon_uk/html/website.rb +0 -38
  67. data/lib/odeon_uk/screening.rb +0 -71
  68. data/test/fixtures/api/film_times/71-100747.plist +0 -0
  69. data/test/fixtures/api/film_times/71-100750.plist +0 -0
  70. data/test/fixtures/api/film_times/71-100790.plist +0 -0
  71. data/test/fixtures/api/film_times/71-14646.plist +0 -0
  72. data/test/fixtures/api/film_times/71-14725.plist +0 -0
  73. data/test/fixtures/api/film_times/71-15086.plist +0 -0
  74. data/test/fixtures/api/film_times/71-15096.plist +0 -0
  75. data/test/fixtures/api/film_times/71-15122.plist +0 -0
  76. data/test/fixtures/api/film_times/71-15130.plist +0 -0
  77. data/test/fixtures/api/film_times/71-15141.plist +0 -0
  78. data/test/fixtures/api/film_times/71-15142.plist +0 -0
  79. data/test/fixtures/api/film_times/71-15143.plist +0 -0
  80. data/test/fixtures/api/film_times/71-15144.plist +0 -0
  81. data/test/fixtures/api/film_times/71-15145.plist +0 -0
  82. data/test/fixtures/api/film_times/71-15170.plist +0 -0
  83. data/test/fixtures/api/film_times/71-15172.plist +0 -0
  84. data/test/fixtures/api/film_times/71-15177.plist +0 -0
  85. data/test/fixtures/api/film_times/71-15179.plist +0 -0
  86. data/test/fixtures/api/film_times/71-15182.plist +0 -0
  87. data/test/fixtures/api/film_times/71-15286.plist +0 -0
  88. data/test/fixtures/api/film_times/71-15360.plist +0 -0
  89. data/test/fixtures/api/film_times/71-15586.plist +0 -0
  90. data/test/fixtures/api/film_times/71-15700.plist +0 -0
  91. data/test/fixtures/api/film_times/71-15718.plist +0 -0
  92. data/test/fixtures/api/film_times/71-15768.plist +0 -0
  93. data/test/fixtures/api/film_times/71-15788.plist +0 -0
  94. data/test/fixtures/api/film_times/71-15793.plist +0 -0
  95. data/test/fixtures/api/film_times/71-15794.plist +0 -0
  96. data/test/fixtures/api/film_times/71-15795.plist +0 -0
  97. data/test/fixtures/api/film_times/71-15796.plist +0 -0
  98. data/test/fixtures/api/film_times/71-15799.plist +0 -0
  99. data/test/fixtures/api/film_times/71-15802.plist +0 -0
  100. data/test/fixtures/api/film_times/71-15814.plist +0 -0
  101. data/test/fixtures/api/film_times/71-15817.plist +0 -0
  102. data/test/fixtures/api/film_times/71-15840.plist +0 -0
  103. data/test/fixtures/html/cinema/105.html +0 -2622
  104. data/test/fixtures/html/cinema/211.html +0 -3241
  105. data/test/fixtures/html/cinema/71.html +0 -3448
  106. data/test/fixtures/html/showtimes/11-imax.html +0 -170
  107. data/test/fixtures/html/showtimes/171-d-box.html +0 -203
  108. data/test/fixtures/html/showtimes/71-0.html +0 -59
  109. data/test/fixtures/html/showtimes/71.html +0 -2395
  110. data/test/fixtures/html/sitemap.html +0 -1303
  111. data/test/lib/odeon_uk/api/cinema_test.rb +0 -165
  112. data/test/lib/odeon_uk/api/screenings_test.rb +0 -58
  113. data/test/lib/odeon_uk/configuration_test.rb +0 -29
  114. data/test/lib/odeon_uk/html/cinema_test.rb +0 -149
  115. data/test/lib/odeon_uk/html/parser/film_with_screenings_test.rb +0 -97
  116. data/test/lib/odeon_uk/html/screenings_test.rb +0 -44
  117. data/test/lib/odeon_uk/html/website_test.rb +0 -67
  118. data/test/lib/odeon_uk/screening_test.rb +0 -92
  119. 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.png)](http://badge.fury.io/rb/odeon_uk)
6
- [![Code Climate](https://codeclimate.com/github/andycroll/odeon_uk.png)](https://codeclimate.com/github/andycroll/odeon_uk)
7
- [![Build Status](https://travis-ci.org/andycroll/odeon_uk.png?branch=master)](https://travis-ci.org/andycroll/odeon_uk)
8
- [![Inline docs](http://inch-ci.org/github/andycroll/odeon_uk.png)](http://inch-ci.org/github/andycroll/odeon_uk)
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 brand="Odeon" name="Odeon Tunbridge Wells" slug="odeon-tunbridge-wells" chain_id="23" url="...">, #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" chain_id="71" url="...">, ...]
35
+ #=> [<OdeonUk::Cinema ...>, <OdeonUk::Cinema ...>, ...]
31
36
 
32
- OdeonUk::Cinema.find_by_id('71')
33
- #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" address="..." chain_id="71" url="...">
37
+ cinema = OdeonUk::Cinema.new(71)
38
+ #=> <OdeonUk::Cinema ...>
34
39
 
35
- OdeonUk::Cinema.find_by_id(71)
36
- #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" address="..." chain_id="71" url="...">
37
-
38
- cinema = OdeonUk::Cinema.find_by_slug('odeon-brighton')
39
- #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" chain_id="71" url="...">
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.chain_id
45
- #=> '71'
53
+ cinema.full_name
54
+ #=> 'Odeon Brighton'
46
55
 
47
- cinema.url
48
- #=> "http://www.odeon.co.uk/cinemas/brighton/71/"
56
+ cinema.id
57
+ #=> 71
49
58
 
50
- cinema.films
51
- #=> [<OdeonUk::Film name="Iron Man 3">, <OdeonUk::Film name="Star Trek: Into Darkness">]
59
+ cinema.postal_code
60
+ #=> 'BN1 2RE'
61
+ ```
52
62
 
53
- cinema.screenings
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
- cinema.screenings_of 'Iron Man 3'
57
- #=> [<OdeonUk::Screening film="Iron Man 3" when="2013-09-09 11:00 UTC" variant="3d">, <OdeonUk::Screening film="Iron Man 3" when="2013-09-09 13:50 UTC" variant="kids">]
65
+ ``` ruby
66
+ OdeonUk::Performance.at(17)
67
+ #=> [<OdeonUk::Performance ...>, <OdeonUk::Performance ...>, ...]
58
68
 
59
- cinema.screenings_of <OdeonUk::Film name="Iron Man 3">
60
- #=> [<OdeonUk::Screening film="Iron Man 3" when="2013-09-09 11:00 UTC" variant="3d">, <OdeonUk::Screening film="Iron Man 3" when="2013-09-09 13:50 UTC" variant="kids">]
61
- ```
69
+ performance = OdeonUk::Performance.at(17).first
70
+ #=> <OdeonUk::Performance ...>
62
71
 
63
- ### Film
72
+ performance.film_name
73
+ #=> 'Star Wars: The Force Awakens'
64
74
 
65
- ``` ruby
66
- OdeonUk::Film.all
67
- #=> [<OdeonUk::Film name="Iron Man 3" slug="iron-man-3">, <OdeonUk::Film name="Star Trek Into Darkness" slug="star-trek-into-darkness">, <OdeonUk::Film name="Captain America: The First Avenger" slug="captain-america-the-first-avenger">, <OdeonUk::Film name="Thor: The Dark World" slug="thor-the-dark-world">]
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
- namespace :fixtures do
27
+ task :fixtures do
30
28
  require 'odeon_uk'
31
29
  require_relative 'rake/fixture_creator'
30
+ require 'fileutils'
32
31
 
33
- desc 'html'
34
- task :html do
35
- FixtureCreator::Html.new(nil).sitemap!
36
- FixtureCreator::Html.new(71).cinema! # brighton
37
- FixtureCreator::Html.new(211).cinema! # bfi imax
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 'forwardable'
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/response'
12
- require_relative './odeon_uk/api/cinema'
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/screening'
12
+ require_relative './odeon_uk/performance'
22
13
 
23
14
  # odeon_uk gem
24
15
  module OdeonUk
@@ -1,115 +1,163 @@
1
1
  module OdeonUk
2
2
  # The object representing a cinema on the Odeon UK website
3
- class Cinema
4
- extend Forwardable
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
- cinema_parser_class.ids.map { |cinema_id| new(cinema_id) }
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] of different address parts
29
+ # @return [Hash] contains :street_address, :extended_address,
30
+ # :locality, :postal_code, :country
51
31
  # @example
52
- # cinema = OdeonUk::Cinema.find('71')
32
+ # cinema = OdeonUk::Cinema.new(3)
53
33
  # cinema.adr
54
- # #=> { street_address: 'Kingswest',
34
+ # #=> {
35
+ # street_address: '44-47 Gardner Street',
36
+ # extended_address: 'North Laine',
55
37
  # locality: 'Brighton',
56
- # postal_code: 'BN1 2RE',
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: street_address,
61
- locality: locality,
62
- postal_code: postal_code,
63
- country_name: 'United Kingdom'
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
- # @return [String] 'Odeon'
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
- # The name of the cinema including the brand
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 = OdeonUk::Cinema.find('71')
77
- # cinema.full_name
78
- # #=> 'Odeon Brighton'
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 ||= cinema_parser.name.gsub('London - ', '').gsub(' - ', ': ')
106
+ @name ||= cinema_hash['siteName'].gsub(/\ALondon /, '').gsub(' - ', ': ')
87
107
  end
88
108
 
89
- # All planned screenings
90
- # @return [Array<OdeonUk::Screening>]
91
- # @example
92
- # cinema = OdeonUk::Cinema.find('71')
93
- # cinema.screenings
94
- # #=> [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." variant="...">, <OdeonUk::Screening ...>]
95
- def screenings
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
- # slug from the hotel name
100
- # @return [String] the slug of the cinema
101
- def slug
102
- @slug ||= full_name.downcase.gsub(/[^0-9a-z ]/, '').gsub(/\s+/, '-')
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.cinema_parser_class
108
- OdeonUk.configuration.method == :api ? Api::Cinema : Html::Cinema
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 cinema_parser
112
- @cinema_parser ||= self.class.cinema_parser_class.new(id)
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 Api
7
+ module Internal
8
8
  # Utility class to make calls to the odeon website
9
- class Response
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