Sha256: b5e5ae47aebaf65fcf7881ccfd641cffa572bc85c640409a3d6a3ae9bcbea8e7
Contents?: true
Size: 892 Bytes
Versions: 2
Compression:
Stored size: 892 Bytes
Contents
module Board class CandidateSearch attr_reader :errors def initialize(client, params = {}) @client = client @params = params @errors = [] end def results initial_search['results'] end def each_result total = initial_search['total'] pages = (total / 10.0).ceil initial_search['results'].each { |r| yield r } (2..pages).each do |page| search = @client.candidate_searches(@params.merge(:page => page)) results = search['results'] results.each { |r| yield r } end end def valid? perform_search and @errors.empty? end private def initial_search @initial_search ||= @client.candidate_searches(@params) rescue Board::Request::Error => e @errors = Yajl::Parser.parse(e.response.body) end alias perform_search initial_search end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
board-client-0.3.0 | lib/board/candidate_search.rb |
board-client-0.2.0 | lib/board/candidate_search.rb |