Module: NicoQuery::Crawler::TagSearch

Defined in:
lib/nicoquery/crawler/tag_search.rb

Class Method Summary collapse

Class Method Details

.each_movie(parsed_movies, &block) ⇒ Object



32
33
34
35
36
# File 'lib/nicoquery/crawler/tag_search.rb', line 32

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

.execute(tag: tag, sort: sort, order: order, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nicoquery/crawler/tag_search.rb', line 10

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