class Ruskino33Parser::Movie

Public Class Methods

new(movie) click to toggle source
# File lib/ruskino33_parser/movie.rb, line 3
def initialize(movie)
  @movie = movie
end

Public Instance Methods

other_days() click to toggle source
# File lib/ruskino33_parser/movie.rb, line 20
def other_days
  @movie.search('.other_days a').map do |other_day|
    {
      date: other_day.text,
      url: "http://www.ruskino33.ru#{other_day.attribute('href')}"
    }
  end
end
schedules() click to toggle source
# File lib/ruskino33_parser/movie.rb, line 11
def schedules
  result = []
  @movie.search('table.sheet tr').each do |tr|
    next if tr.search('td').first.text == 'Зал'
    result += prepare_schedule(tr.search('td'))
  end
  result
end
title() click to toggle source
# File lib/ruskino33_parser/movie.rb, line 7
def title
  @movie.search('.film_desc h3').first.text
end

Private Instance Methods

prepare_price(prices) click to toggle source
# File lib/ruskino33_parser/movie.rb, line 42
def prepare_price(prices)
  prices = prices.split(';').map { |price| price.sub!('руб', '').to_i }
  { vip: prices[0], doble_seat: prices[1], economy: prices[2] }
end
prepare_schedule(cell) click to toggle source
# File lib/ruskino33_parser/movie.rb, line 31
def prepare_schedule(cell)
  cell.last.search('a').map do |time|
    {
      hall: cell.first.text,
      time: "#{time.text}:#{time.next.text}",
      prices: prepare_price(time.attribute('title').text),
      book_url: "http://www.ruskino33.ru#{time.attribute('href')}#session_info"
    }
  end
end