module TheatresReport
Render cinema session listings as an Ibis-style reply card.
Constants
- MAX_MOVIES_PER_CINEMA
- MAX_TIMES_PER_MOVIE
- STYLE_BANNER
Public Instance Methods
Source
# File lib/theatres_report.rb, line 45 def build_report(venues, parsed) town = parsed[:town].to_s if venues.empty? return IrcReply.card( tag: "THEATRES", title: banner_title(town), body_lines: [ "No cinema session times found in quick lookup.", "Browse: #{TheatresSearch.build_search_url(parsed[:search_town] || town)}" ], footer_parts: [TextUtil.title_words(town), "try a nearby city"], heading_style: STYLE_BANNER ) end lines = venues.flat_map do |venue| label = cinema_label(venue) movies = venue[:movies].first(MAX_MOVIES_PER_CINEMA) movies.map { |movie| format_movie_line(label, movie) } end IrcReply.card( tag: "THEATRES", title: banner_title(town), body_lines: lines, footer_parts: footer_parts(venues, parsed), heading_style: STYLE_BANNER ) end
Source
# File lib/theatres_report.rb, line 29 def cinema_label(venue) chain = venue[:chain].to_s.strip name = venue[:cinema].to_s.strip chain.empty? ? name : "#{chain} #{name}" end
Source
# File lib/theatres_report.rb, line 21 def format_movie_line(cinema_label, movie) title = movie[:title].to_s.strip rating = movie[:rating].to_s.strip title_label = rating.empty? ? title : "#{title} (#{rating})" times = movie[:times].first(MAX_TIMES_PER_MOVIE).join(", ") "#{cinema_label} โ #{title_label}: #{times}" end