require_relative './remote_searcher'
require_relative './result_item'

module Gugl
  module Search
    class DataGetter
      attr_accessor :query, :limit
  
      def get
        searcher.search(query, limit) do |items|
          items.map(&method(:build_item))
        end
      end
  
      def searcher
        @searcher ||= RemoteSearcher.new
      end
  
      private
  
      def build_item(item)
        ResultItem.new(item)
      end
    end
  end
end