Sha256: 73677aa23e02c0489ed15c24a1396f36bf7f801a375d41801b20ea19a506c65a

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# This class is used by the Historics examples to remove the noise of
# dealing with command line arguments.
#

# Include the DataSift library
require File.dirname(__FILE__) + '/../../lib/datasift'

class Env
	attr_reader :user, :args

	def initialize(args = false)
		if args === false
			args = ARGV
		end

		abort('Please specify your DataSift username and API key as the first two command line arguments!') unless args.size() >= 2

		username = args.shift
		api_key = args.shift
		@user = DataSift::User.new(username, api_key)

		@args = args
	end

	def displayHistoricDetails(historic)
		puts 'Playback ID: ' + historic.hash
		puts 'Stream hash: ' + historic.stream_hash
		puts 'Name:        ' + historic.name
		puts 'Start time:  ' + historic.start_date.strftime('%Y-%m-%d %H:%M:%S')
		puts 'End time:    ' + historic.end_date.strftime('%Y-%m-%d %H:%M:%S')
		puts 'Sources:     ' + historic.sources.join(', ')
		puts 'Sample:      ' + String(historic.sample)
		puts 'Created at:  ' + (historic.created_at.nil? ? 'None' : historic.created_at.strftime('%Y-%m-%d %H:%M:%S'))
		puts 'Status:      ' + historic.status
		puts '--'
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datasift-2.1.1 examples/historics/env.rb
datasift-2.1.0 examples/historics/env.rb
datasift-2.1.0.beta examples/historics/env.rb
datasift-2.0.4 examples/historics/env.rb
datasift-2.0.3 examples/historics/env.rb
datasift-2.0.2 examples/historics/env.rb
datasift-2.0.1 examples/historics/env.rb
datasift-2.0.0 examples/historics/env.rb