Sha256: 9e36e9c821a24a76c03529c4aca3c25a2f83c33dd8a1668960645aedce4710a6

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

require "nicoquery/api/tag_search_rss"
require "nicoquery/object_mapper/tag_search_rss"
require "nori"


module NicoQuery
  module Crawler
    module TagSearch
      def execute(tag: tag, sort: sort, order: order, &block)
        page = 0

        loop do
          command = nil
          page += 1

          tag_search_object = NicoQuery::Object::TagSearch.new tag: tag, sort: sort, order: order, page: page
          self.each_movie(tag_search_object.movies) do |movie|
            command = block.call movie
            break if command == :break || command != :continue
          end

          break if command == :break || command != :continue
        end
      end

      private

      def continue; :continue end
      def stop; :stop end

      def each_movie(parsed_movies, &block)
        while parsed_movies.length > 0 do
          block.call parsed_movies.shift
        end
      end

      module_function :execute
      module_function :each_movie
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nicoquery-0.0.2.3 lib/nicoquery/crawler/tag_search.rb
nicoquery-0.0.2.2 lib/nicoquery/crawler/tag_search.rb
nicoquery-0.0.2.1 lib/nicoquery/crawler/tag_search.rb