Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created April 25, 2012 19:14
Show Gist options
  • Save luckyruby/2492395 to your computer and use it in GitHub Desktop.
Save luckyruby/2492395 to your computer and use it in GitHub Desktop.
source 'http://rubygems.org'
gem 'rails', '3.2.3'
gem 'redis'
gem 'execjs'
platforms :mri do
gem 'unicorn'
gem 'pg'
gem 'therubyracer'
end
platforms :jruby do
gem 'activerecord-jdbcpostgresql-adapter'
gem 'jdbc-postgres'
gem 'jruby-openssl'
gem 'json'
gem 'therubyrhino'
end
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
group :development do
gem 'nifty-generators'
gem 'ruby-prof'
gem 'capistrano'
gem 'capistrano-ext'
gem 'rvm-capistrano'
end
gem "mocha", :group => :test
def results
#validation sequence
enough_info? &&
pickup_location_exists? &&
valid_pickup_date? &&
valid_pickup_time? &&
valid_return_date? &&
valid_return_time? &&
pickup_in_future? &&
pickup_before_return? &&
return_location_exists? &&
pickup_location_open? &&
return_location_open? &&
cars_available? &&
rates_available?
@results[:function] = case @request[:function]
when 'AS' then 'AS'
when 'RQ' then 'RQ'
when 'AN' then 'ANS'
end
@results[:pickup_location] = @request[:pickup_location] #<pickup_location>
@results[:pickup_location_airport_code] = @pickup_location_airport_code if @pickup_location_airport_code.present? #<pickup_location_apid>
@results[:pickup_location_name] = @pickup_location.name if @pickup_location #<location_name>
@results[:pickup_location_type] = @pickup_location.location_type.code if @pickup_location && @request[:source] != 'INTERNET' #<in_terminal>
@results[:pickup_date] = @request[:pickup_date] #<pickup_date>
@results[:pickup_time] = @request[:pickup_time] #<pickup_time>
@results[:return_location] = @request[:return_location] #<return_location>
@results[:return_location_airport_code] = @return_location_airport_code if @return_location_airport_code #<return_location_apid>
@results[:return_date] = @request[:return_date] #<return_date>
@results[:return_time] = @request[:return_time] #<return_time>
if @rental_length.present?
@results[:rental_length] = @rental_length[:days].to_s.rjust(3,"0") + @rental_length[:hours].to_s.rjust(2,"0") #<rental_length>
@results[:rental_days] = @rental_length[:days].to_s.rjust(3,"0") #<rental_days>
@results[:rental_hours] = @rental_length[:hours].to_s.rjust(2,"0") #<rental_hours>
end
@results[:error_number] = @error_number #<error_number>
@results[:error_text] = @error_text if @error_text.present? #<error_text>
if @rates.present?
@results[:rates] = Utility.deep_copy(@rates) #<rate_(record locator)>
@results[:rates].each { |rate| rate.delete_if { |key| [ :text_rule, :min_advanced ].include? key } } #text rule is only displayed for an RQ
case @request[:function]
when 'RQ','AN'
rate = @rates.first
@results[:payment_options] = @pickup_location.payment_options.map(&:code).join("*") #<forms_of_payment>
@results[:pickup_location_address] = @pickup_location.full_address #<pickup_addr>
@results[:operating_hours] = @operating_hours #<hours_operation>
@results[:text_rule] = rate[:text_rule] #<text_rule>
@results[:min_advanced] = rate[:min_advanced] #<advance_qty>
@results[:min_advanced_unit] = 'MIN' #<advance_unit>
@results[:min_length] = rate[:min_length] #<min_rate_qty>
@results[:min_length_unit] = 'H' #<min_rate_units>
@results[:base_length] = rate[:base_length] #<max_rate_qty>
@results[:base_length_unit] = 'H' #<max_rate_units>
@results[:max_length] = rate[:max_length] #<max_rental_qty>
@results[:max_length_unit] = 'H' #<max_rental_units>
@results[:pickup_location_code] = @pickup_location.code
@results[:return_location_code] = @return_location.code
@results[:pickup_location_timezone] = @pickup_location.timezone
@results[:return_location_timezone] = @return_location.timezone
@results[:pickup_notes] = @pickup_location.pickup_notes
end
end
@results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment