Sha256: 9e407b6f483c706e0d8f1ab28203cd38d4832e3dba9952c97b1f86ff0d4503a5

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Ruskino33Parser
  class Anonce
    attr_accessor :url, :doc

    # date: '2015-03-11'
    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.0 lib/ruskino33_parser/anonce.rb