Class: Cinebase::Performance

Inherits:
Object
  • Object
show all
Defined in:
lib/cinebase/performance.rb

Overview

Performance base class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Performance

Returns a new instance of Performance.



10
11
12
13
14
15
16
17
18
# File 'lib/cinebase/performance.rb', line 10

def initialize(options)
  @booking_url = options.fetch(:booking_url, nil)
  @cinema_name = options.fetch(:cinema_name)
  @cinema_id   = options.fetch(:cinema_id)
  @dimension   = options.fetch(:dimension, '2d')
  @film_name   = options.fetch(:film_name)
  @time        = options.fetch(:starting_at)
  @variant     = options.fetch(:variant, [])
end

Instance Attribute Details

#booking_urlObject (readonly)

Returns the value of attribute booking_url.



4
5
6
# File 'lib/cinebase/performance.rb', line 4

def booking_url
  @booking_url
end

#cinema_idObject (readonly)

Returns the value of attribute cinema_id.



6
7
8
# File 'lib/cinebase/performance.rb', line 6

def cinema_id
  @cinema_id
end

#cinema_nameObject (readonly)

Returns the value of attribute cinema_name.



7
8
9
# File 'lib/cinebase/performance.rb', line 7

def cinema_name
  @cinema_name
end

#dimensionObject (readonly)

Returns the value of attribute dimension.



5
6
7
# File 'lib/cinebase/performance.rb', line 5

def dimension
  @dimension
end

#film_nameObject (readonly)

Returns the value of attribute film_name.



8
9
10
# File 'lib/cinebase/performance.rb', line 8

def film_name
  @film_name
end

Class Method Details

.at(cinema_id) ⇒ Object

Implement to deliver an Array of Screening objects



21
22
23
# File 'lib/cinebase/performance.rb', line 21

def self.at(cinema_id)
  fail NotImplementedError, "This #{self.class} cannot respond to: "
end

Instance Method Details

#showing_onObject



34
35
36
# File 'lib/cinebase/performance.rb', line 34

def showing_on
  starting_at.to_date
end

#starting_atObject



25
26
27
28
29
30
31
32
# File 'lib/cinebase/performance.rb', line 25

def starting_at
  @starting_at ||=
    if @time.utc?
      @time
    else
      TZInfo::Timezone.get('Europe/London').local_to_utc(@time)
    end
end

#variantObject



38
39
40
41
# File 'lib/cinebase/performance.rb', line 38

def variant
  @variant = @variant.split(' ') if @variant.is_a?(String)
  @variant.map(&:downcase).sort.uniq
end