odeon_uk 1.1.2 → 1.1.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTZjMGMzNjQxNzUwZjUxZTE2OWY3NDRiNjY5ZmIxNWM0NjFjZjZiZg==
4
+ NDQxYWI5ZWRlNDQ1YThkYjc2NzU5MWJlNTA5ZTM3MGQyMzE3ZDVhOA==
5
5
  data.tar.gz: !binary |-
6
- N2Y2MGY0NWRmYjBiZDEwYjU2ZGJiYWI4ODVlMjg3YmM5YWFkMWYxYQ==
6
+ ZGRjMjg4Y2M5YTMxZDU5MWQ2ZDIxZTUyMDAyODk3ZWFlZDcwODdmOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzA0MzM5ZTc2ZjI4ZjBiNTI3MTQzY2NiZTRkZTE4MjM0NzE4NDE0ZGRkNWFi
10
- YWUxMDA5NTA4ZTUyNGYwYjIyZTdjZTMxM2QyY2M0MWVjNzI0MjBjOTYwZjY5
11
- OTYxOGZjOTQ1MTk4NTY2NzVlZWY0NjBhYWY1YzQ0ODI3ZWNkZWE=
9
+ YjQ0ZGEzOTAwNzczOWVkZmY1NjkzODYyYThiMWQ4NGYxNjMzOWUxOGEzYzAw
10
+ YzQwYzE3YzQ4ZmJhZWU2MTdmMWI2ZjZmMjUxZDQ0OTA1MWY5N2VkMDVlZjMz
11
+ ZjNlYzdjOTdhNzk2M2NmYWMzYmIwZTVhMjBkODcyMTJkYTEyOTc=
12
12
  data.tar.gz: !binary |-
13
- YWYxZTY5NmQyZmJiMzhkMDY2ZDhhNGFmYWVmYzE3ZjIwM2U0NmFiZGYzZmQ0
14
- NDZmMjFkMWE1Y2YzNmFiZDg2YmViNDQ0Zjg1ODA1ODYyODkyYmI2NTE0MWZk
15
- MDMxMjg0NDFjNzRlNDllODA1ZTRiNmE0YzViMTQ0ZjE4OWE4NDk=
13
+ NjdmNWExNzI5NWJhYTg4YjQzOTdkMTRkYjQ5ZjVjNzMyOTM2YWM3NTY5M2Vk
14
+ ZmNhYTVmZTdhMmZhNWU1M2JjZTRiYzA4YWMzZDFhY2Q5MzYyMTZmNWIxMTlk
15
+ YjYyODFjMWNiNzZlZWQ2OWQxMjRhZGUyOTM2OWQ3MGU1OTJmMTQ=
@@ -1,24 +1,23 @@
1
1
  module OdeonUk
2
2
 
3
- # Public: The object representing a cinema on the Odeon UK website
3
+ # The object representing a cinema on the Odeon UK website
4
4
  class Cinema
5
5
 
6
- # Public: Returns the String brand of the cinema #=> 'Odeon'
6
+ # @return [String] the brand of the cinema
7
7
  attr_reader :brand
8
- # Public: Returns the Integer id of the cinema on teh odeon website
8
+ # @return [Integer] the numeric id of the cinema on the Odeon website
9
9
  attr_reader :id
10
- # Public: Returns the String name of the cinema
10
+ # @return [String] the name of the cinema
11
11
  attr_reader :name
12
- # Public: Returns the String slug of the cinema
12
+ # @return [String] the slug of the cinema
13
13
  attr_reader :slug
14
- # Public: Returns the String url of the cinema's page on odeon.co.uk
14
+ # @return [String] the url of the cinema on the Odeon website
15
15
  attr_reader :url
16
16
 
17
- # Public: Initialize a cinema
18
- #
19
- # id - Integer/String of the cinema on the odeon website
20
- # name - String of cinema name
21
- # url - String of cinema url on the odeon website
17
+ # @param [Integer, String] id cinema id
18
+ # @param [String] name cinema name
19
+ # @param [String] url url on Odeon website
20
+ # @return [OdeonUk::Cinema]
22
21
  def initialize(id, name, url)
23
22
  @brand = 'Odeon'
24
23
  @id = id.to_i
@@ -27,31 +26,23 @@ module OdeonUk
27
26
  @url = (url[0] == '/') ? "http://www.odeon.co.uk#{url}" : url
28
27
  end
29
28
 
30
- # Public: Return basic cinema information for all Odeon cinemas
31
- #
32
- # Examples
33
- #
29
+ # Return basic cinema information for all cinemas
30
+ # @return [Array<OdeonUk::Cinema>]
31
+ # @example
34
32
  # OdeonUk::Cinema.all
35
- # # => [<OdeonUk::Cinema brand="Odeon" name="Odeon Tunbridge Wells" slug="odeon-tunbridge-wells" id=23 url="...">, #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" chain_id="71" url="...">, ...]
36
- #
37
- # Returns an array of hashes of cinema information.
33
+ # #=> [<OdeonUk::Cinema brand="Odeon" name="Odeon Tunbridge Wells" slug="odeon-tunbridge-wells" id=23 url="...">, #=> <OdeonUk::Cinema brand="Odeon" name="Odeon Brighton" slug="odeon-brighton" chain_id="71" url="...">, ...]
38
34
  def self.all
39
35
  cinema_links.map do |link|
40
36
  new_from_link link
41
37
  end
42
38
  end
43
39
 
44
- # Public: Return single cinema information for an Odeon cinema
45
- #
46
- # id_string - a string/int representing the cinema id
47
- # of the format '32'/32 as used on the odeon.co.uk website
48
- #
49
- # Examples
50
- #
40
+ # Find a single cinema
41
+ # @param [Integer, String] id the cinema id of the format 71/'71' as used on the odeon.co.uk website
42
+ # @return [OdeonUk::Cinema, nil]
43
+ # @example
51
44
  # OdeonUk::Cinema.find('71')
52
- # # => <OdeonUk::Cinema brand="Odeon" name="Brighton" slug="brighton" id=71 url="...">
53
- #
54
- # Returns an Odeon::Cinema or nil if none was found
45
+ # #=> <OdeonUk::Cinema brand="Odeon" name="Brighton" slug="brighton" id=71 url="...">
55
46
  def self.find(id)
56
47
  id = id.to_i
57
48
  return nil unless id > 0
@@ -59,18 +50,12 @@ module OdeonUk
59
50
  all.select { |cinema| cinema.id == id }[0]
60
51
  end
61
52
 
62
- # Public: Returns adress hash of an Odeon cinema
63
- #
64
- # Examples
65
- #
53
+ # Address of the cinema
54
+ # @return [Hash] of different address parts
55
+ # @example
66
56
  # cinema = OdeonUk::Cinema.find('71')
67
57
  # cinema.adr
68
- # # => { street_address: 'Kingswest',
69
- # locality: 'Brighton',
70
- # postal_code: 'BN1 2RE',
71
- # country_name: 'United Kingdom' }
72
- #
73
- # Returns an array of strings or nil
58
+ # #=> { street_address: 'Kingswest', locality: 'Brighton', postal_code: 'BN1 2RE', country_name: 'United Kingdom' }
74
59
  def adr
75
60
  {
76
61
  street_address: street_address,
@@ -80,15 +65,12 @@ module OdeonUk
80
65
  }
81
66
  end
82
67
 
83
- # Public: Returns films for an Odeon cinema
84
- #
85
- # Examples
86
- #
68
+ # Films with showings scheduled at this cinema
69
+ # @return [Array<OdeonUk::Film>]
70
+ # @example
87
71
  # cinema = OdeonUk::Cinema.find('71')
88
72
  # cinema.films
89
- # # => [<OdeonUk::Film name="Iron Man 3">, <OdeonUk::Film name="Star Trek Into Darkness">]
90
- #
91
- # Returns an array of Odeon::Film objects
73
+ # #=> [<OdeonUk::Film name="Iron Man 3">, <OdeonUk::Film name="Star Trek Into Darkness">]
92
74
  def films
93
75
  film_nodes.map do |node|
94
76
  parser = OdeonUk::Internal::FilmWithScreeningsParser.new node.to_s
@@ -96,42 +78,33 @@ module OdeonUk
96
78
  end.uniq
97
79
  end
98
80
 
99
- # Public: Returns the locality (town) of an Odeon cinema
100
- #
101
- # Examples
102
- #
81
+ # The locality (town) of the cinema
82
+ # @return [String]
83
+ # @example
103
84
  # cinema = OdeonUk::Cinema.find('71')
104
85
  # cinema.locality
105
- # # => 'Brighton'
106
- #
107
- # Returns a String
86
+ # #=> 'Brighton'
108
87
  def locality
109
88
  address_node.text.match(/\w+(\s\w+){0,}\s+(\w+(\s\w+){0,})/)[2]
110
89
  end
111
90
 
112
91
 
113
- # Public: Returns the postal code of an Odeon cinema
114
- #
115
- # Examples
116
- #
92
+ # Post code of the cinema
93
+ # @return [String]
94
+ # @example
117
95
  # cinema = OdeonUk::Cinema.find('71')
118
96
  # cinema.postal_code
119
- # # => 'BN1 2RE'
120
- #
121
- # Returns a String
97
+ # #=> 'BN1 2RE'
122
98
  def postal_code
123
99
  address_node.text.match(/[A-Z]{1,2}\d{1,2}[A-Z]?\s\d{1,2}[A-Z]{1,2}/)[0]
124
100
  end
125
101
 
126
- # Public: Returns screenings for an Odeon cinema
127
- #
128
- # Examples
129
- #
102
+ # All planned screenings
103
+ # @return [Array<OdeonUk::Screening>]
104
+ # @example
130
105
  # cinema = OdeonUk::Cinema.find('71')
131
106
  # cinema.screenings
132
- # # => [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
133
- #
134
- # Returns an array of Odeon::Screening objects
107
+ # #=> [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
135
108
  def screenings
136
109
  film_nodes.map do |node|
137
110
  parser = OdeonUk::Internal::FilmWithScreeningsParser.new node.to_s
@@ -143,31 +116,27 @@ module OdeonUk
143
116
  end.flatten
144
117
  end
145
118
 
146
- # Public: Returns screenings for particular film at an Odeon cinema
147
- #
148
- # Examples
149
- #
119
+ # Screenings for particular film
120
+ # @param [OdeonUk::Film, String] film a film object or title of the film
121
+ # @return [Array<Odeon::Screening>]
122
+ # @example
150
123
  # cinema = OdeonUk::Cinema.find('71')
151
- # cinema.screenings_of 'Iron Man 3'
152
- # # => [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
153
- # cinema.screenings_of <OdeonUk::Film name="Iron Man 3">
154
- # # => [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
155
- #
156
- # Returns an array of Odeon::Screening objects
124
+ # cinema.screenings_of('Iron Man 3')
125
+ # #=> [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
126
+ # iron_man_3 = OdeonUk::Film.new "Iron Man 3"
127
+ # cinema.screenings_of(iron_man_3)
128
+ # #=> [<OdeonUk::Screening film_name="Iron Man 3" cinema_name="Brighton" when="..." varient="...">, <OdeonUk::Screening ...>]
157
129
  def screenings_of film
158
130
  film_name = (film.is_a?(OdeonUk::Film) ? film.name : film)
159
131
  screenings.select { |s| s.film_name == film_name }
160
132
  end
161
133
 
162
- # Public: Returns the street adress of an Odeon cinema
163
- #
164
- # Examples
165
- #
134
+ # The street adress of the cinema
135
+ # @return a String
136
+ # @example
166
137
  # cinema = OdeonUk::Cinema.find('71')
167
138
  # cinema.street_address
168
- # # => 'Kingswest'
169
- #
170
- # Returns a String
139
+ # #=> 'Kingswest'
171
140
  def street_address
172
141
  address_node.text.match(/\A\s+(\w+(\s\w+){0,})/)[1]
173
142
  end
data/lib/odeon_uk/film.rb CHANGED
@@ -1,50 +1,45 @@
1
1
  module OdeonUk
2
2
 
3
- # Public: The object representing a film on the Odeon UK website
3
+ # The object representing a film on the Odeon UK website
4
4
  class Film
5
5
  include Comparable
6
6
 
7
- # Public: Returns the String name of the film
7
+ # @return [String] the name of the film
8
8
  attr_reader :name
9
- # Public: Returns the String slug of the film
9
+ # @return [String] the normalized slug derived from the film name
10
10
  attr_reader :slug
11
11
 
12
- # Public: Initialize a screening
13
- #
14
- # name - String of the film name
12
+ # @param [String] name the film name
13
+ # @return [OdeonUk::Film]
15
14
  def initialize(name)
16
15
  @name = name
17
16
  @slug = name.downcase.gsub(/[^0-9a-z ]/,'').gsub(/\s+/, '-')
18
17
  end
19
18
 
20
- # Public: Allows sort on objects
19
+ # Allows sort on objects
20
+ # @param [OdeonUk::Film] other another film object
21
+ # @return [Integer] -1, 0 or 1
21
22
  def <=> other
22
23
  self.slug <=> other.slug
23
24
  end
24
25
 
25
- # Public: Check an object is the same as another object.
26
- #
27
- # True if both objects are the same exact object, or if they are of the same
28
- # type and share an equal slug
29
- #
30
- # Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
31
- #
32
- # object - object to be compared
33
- #
34
- # Returns Boolean
26
+ # Check an object is the same as another object.
27
+ # @param [OdeonUk::Film] other another film
28
+ # @return [Boolean] True if both objects are the same exact object, or if
29
+ # they are of the same type and share an equal slug
30
+ # @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
35
31
  def eql? other
36
32
  self.class == other.class && self == other
37
33
  end
38
34
 
39
- # Public: generates hash of slug in order to allow two records of the same
40
- # type and id to work with something like:
35
+ # Generates hash of slug in order to allow two records of the same type and
36
+ # id to work with something like:
41
37
  #
42
38
  # [ Film.new('ABC'), Film.new('DEF') ] & [ Film.new('DEF'), Film.new('GHI') ]
43
39
  # #=> [ Film.new('DEF') ]
44
40
  #
45
- # Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
46
- #
47
- # Returns an Integer hash of the slug
41
+ # @return [Integer] hash of slug
42
+ # @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
48
43
  def hash
49
44
  self.slug.hash
50
45
  end
@@ -1,12 +1,19 @@
1
1
  module OdeonUk
2
+
3
+ # Internal utility classes: Do not use
4
+ # @api private
2
5
  module Internal
3
- # Private: An object to parse a film HTML snippet
6
+
7
+ # Parses a chunk of HTML to derive movie showing data
4
8
  class FilmWithScreeningsParser
5
9
 
10
+ # @param [String] film_html a chunk of html
6
11
  def initialize(film_html)
7
12
  @nokogiri_html = Nokogiri::HTML(film_html)
8
13
  end
9
14
 
15
+ # The film name
16
+ # @return [String]
10
17
  def film_name
11
18
  name = @nokogiri_html.css('.presentation-info h4 a').children.first.to_s
12
19
 
@@ -34,6 +41,13 @@ module OdeonUk
34
41
  name = name.gsub /\s+\z/, '' # remove trailing spaces
35
42
  end
36
43
 
44
+ # Showings
45
+ # @return [Hash]
46
+ # @example
47
+ # {
48
+ # "2D" => [[Time.utc, 'http://www...'], [Time.utc, 'http://www...']],
49
+ # "3D" => [[Time.utc, 'http://www...']]
50
+ # }
37
51
  def showings
38
52
  tz = TZInfo::Timezone.get('Europe/London')
39
53
  @nokogiri_html.css('.times-all.accordion-group').inject({}) do |result, varient_node|
@@ -1,34 +1,32 @@
1
1
  module OdeonUk
2
2
 
3
- # Public: The object representing a screening of a film on the Odeon UK website
3
+ # The object representing a single screening of a film on the Odeon UK website
4
4
  class Screening
5
5
 
6
- # Public: Returns the booking URL on the cinema website
6
+ # @return [String] the booking URL on the cinema website
7
7
  attr_reader :booking_url
8
- # Public: Returns the String name of the cinema
8
+ # @return [String] the cinema name
9
9
  attr_reader :cinema_name
10
- # Public: Returns the String name of the film
10
+ # @return [String] the film name
11
11
  attr_reader :film_name
12
- # Public: Returns the Time of the screening
12
+ # @return [Time] the UTC time of the screening
13
13
  attr_reader :when
14
- # Public: Returns the Type of screening (3d, baby, kids, live)
14
+ # @return [String] the type of screening (2D, 3D, IMAX...)
15
15
  attr_reader :varient
16
16
 
17
- # Public: Initialize a screening
18
- #
19
- # film_name - String of the film name
20
- # cinema_name - String of the cinema name on the Odeon website
21
- # time - Time representing the time of the screening (24 hour clock)
22
- # varient - String representing the type of showing (e.g. 3d/baby/live)
17
+ # @param [String] film_name the film name
18
+ # @param [String] the cinema name
19
+ # @param [Time] time datetime of the screening (UTC preferred)
20
+ # @param [String] booking_url direct link to the booking page for this screening
21
+ # @param [String] varient the type of showing (e.g. 3d/baby/live)
23
22
  def initialize(film_name, cinema_name, time, booking_url=nil, varient=nil)
24
23
  @cinema_name, @film_name, @varient = cinema_name, film_name, varient
25
24
  @booking_url = booking_url
26
25
  @when = time.utc? ? time : TZInfo::Timezone.get('Europe/London').local_to_utc(time)
27
26
  end
28
27
 
29
- # Public: The Date of the screening
30
- #
31
- # Returns a Date
28
+ # The date of the screening
29
+ # @return [Date]
32
30
  def date
33
31
  @when.to_date
34
32
  end
@@ -1,3 +1,6 @@
1
+ # Ruby interface for http://www.odeon.co.uk
2
+ # @version 1.1.3
1
3
  module OdeonUk
2
- VERSION = "1.1.2"
4
+ # Gem version
5
+ VERSION = "1.1.3"
3
6
  end
data/lib/odeon_uk.rb CHANGED
@@ -13,5 +13,4 @@ require_relative './odeon_uk/film'
13
13
  require_relative './odeon_uk/screening'
14
14
 
15
15
  module OdeonUk
16
- # Your code goes here...
17
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odeon_uk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake