Sha256: bafb5dcc5167320e4458c078fc2dc3864f25cfe16bd731449eb3027e3827fe11

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

module Ruskino33Parser
  class Announce
    attr_accessor :url, :doc, :date

    def initialize(attributes = {})
      @date = attributes[:date].nil? ? Date.today : Date.parse(attributes[:date].to_s)
      params = { action: :anonce, date: date.strftime("%d.%m.%Y") }
      @url = "http://www.ruskino33.ru/cgi-bin/webkino2/webkino.pl?#{URI.encode_www_form(params)}"
      @doc = Nokogiri::HTML(File.open('./spec/factories/anonce.html')) if attributes[:test] == true
    end

    def movies
      doc.search('.one_film_cut').map { |movie| Ruskino33Parser::Movie.new(movie) }
    end

    private

    def doc
      @doc ||= Ruskino33Parser.parse url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruskino33_parser-0.1.2 lib/ruskino33_parser/announce.rb