Sha256: 9c0fc78f6d28dc2e72784737869286c764db9497cc5211a4c37bf8f59ccac0a5

Contents?: true

Size: 969 Bytes

Versions: 3

Compression:

Stored size: 969 Bytes

Contents

module GnipApi
  module Apis
    module Search
      class Query
        attr_accessor :rules, :from_date, :to_date, :max_results, :next, :publisher
        
        def initialize params={}
          @rules = params[:rules]
          @from_date = params[:from_date]
          @to_date = params[:to_date]
          @max_results = params[:max_results]
          @next = params[:next]
          @publisher = params[:publisher]
        end

        def to_json
          hash = {}
          hash['query'] = @rules
          hash['publisher'] = @publisher
          hash['fromDate'] = @from_date.to_time.utc.strftime('%Y%m%d%H%M') if @from_date
          hash['toDate'] = @to_date.to_time.utc.strftime('%Y%m%d%H%M') if @to_date
          hash['next'] = @next if @next
          hash['maxResults'] = @max_results if @max_results
          hash.to_json
        end

        def valid?
        end

        private
        def validate
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gnip_api-0.0.4 lib/gnip_api/apis/search/query.rb
gnip_api-0.0.3 lib/gnip_api/apis/search/query.rb
gnip_api-0.0.2 lib/gnip_api/apis/search/query.rb