Sha256: c44b2bdfbd8ed362f1482ff8424fa2b48365754e10db26070609c7c637c8b27a
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
module OdeonUk # Internal utility classes: Do not use # @api private module Internal # Sanitize and standardize film titles class TitleSanitizer # strings and regex to be removed REMOVE = [ /\s+[23][dD]/, # dimension 'Autism Friendly Screening -', # autism screening /\ACinemagic \d{1,4} \-/, # cinemagic /\(encore.+\)/i, # encore for NT Live /\(live\)/i, # live in brackets 'UKJFF -', # UK Jewish festival prefix ] # regexes and their replacements REPLACE = { /Bolshoi - (.*)/ => 'Bolshoi: ', /Globe On Screen: (.*)/ => 'Globe: ', /Met Opera - (.*)/ => 'Met Opera: ', /National Theatre Live - (.*)/ => 'National Theatre: ', /NT Live - (.*)/ => 'National Theatre: ', /ROH - (.*)/ => 'Royal Opera House: ', /(.*)\- RSC Live \d{1,4}/ => 'Royal Shakespeare Company: ' } # @param [String] title a film title def initialize(title) @title = title end # sanitized and standardized title # @return [String] title def sanitized @sanitzed ||= begin sanitized = @title REMOVE.each do |pattern| sanitized.gsub! pattern, '' end REPLACE.each do |pattern, prefix| sanitized.gsub!(pattern) { |_| prefix + $1 } end sanitized.squeeze(' ').strip end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
odeon_uk-2.0.2 | lib/odeon_uk/internal/title_sanitizer.rb |
odeon_uk-2.0.1 | lib/odeon_uk/internal/title_sanitizer.rb |
odeon_uk-2.0.0 | lib/odeon_uk/internal/title_sanitizer.rb |