Class: PicturehouseUk::Internal::TitleSanitizer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/picturehouse_uk/internal/title_sanitizer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Sanitize and standardize film titles

Constant Summary collapse

REMOVE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

strings and regex to be removed

[
  /\s\[(AS LIVE:\s*)?[ACPGU1258]+\]/, # regular certificate
  /\s+[23][dD]/,                      # 2d or 3d from title
  /\s\[NO CERT\]/,                    # no certificate
  /\s\[\]/,                           # blank certificate
  /ourscreen\: /,                     # ourscreen
  /\s\(Re(\: \d{0,4})?\)/i,           # Re-release
  /\s\[CERT TBC\]/,                   # certificate TBC
  /\s?\-\s?autism.*ing\s?/i,          # austim screening
  /\s?\+\s?Q\&A\.?/i,                 # +Q&A
  /KIDS CLUB\s*/i,                    # kids club
  /DISCOVER TUE\s*/i,                 # discover tue
  /FREE Screening\s*-\s*/i            # free screening
]
REPLACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

regexes and their replacements

{
  /Met\.? Encore:\s*(.*)/ => 'Met Opera:',
  /Met\.? Opera:\s*(.*)/  => 'Met Opera: ',
  /NT Encore:\s*(.*)/     => 'National Theatre:',
  /NT Live:\s*(.*)/       => 'National Theatre:',
  /ROH\.? Live:\s*(.*)/   => 'Royal Opera House:',
  /RSC\.? Live:\s*(.*)/   => 'Royal Shakespeare Company:',
  /RSC\.? Encore:\s*(.*)/ => 'Royal Shakespeare Company:'
}

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ TitleSanitizer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TitleSanitizer.

Parameters:

  • title (String)

    a film title



34
35
36
# File 'lib/picturehouse_uk/internal/title_sanitizer.rb', line 34

def initialize(title)
  @title = title
end

Instance Method Details

#sanitizedString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

sanitized and standardized title

Returns:

  • (String)

    title



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/picturehouse_uk/internal/title_sanitizer.rb', line 40

def sanitized
  @sanitzed ||= begin
    sanitized = @title.gsub('&', '&')
    REMOVE.each do |pattern|
      sanitized.gsub! pattern, ''
    end
    REPLACE.each do |pattern, prefix|
      sanitized.gsub!(pattern) { |_| prefix + $1 }
    end
    sanitized.squeeze(' ').strip
  end
end