module PortalGun
Constants
- RUBY_VERSIONS
- VERSION
Public Class Methods
correct_date?(supplied_date)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 182 def self.correct_date?(supplied_date) begin if eval(supplied_date).to_date.is_a?(Date) true else false end rescue false end end
has_p?(input)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 164 def self.has_p?(input) input.include?('p') end
latest?(supplied_date, inspected_date)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 160 def self.latest?(supplied_date, inspected_date) inspected_date < supplied_date end
minor(input)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 168 def self.minor(input) input[0..2] end
minor_already_present?(minors, new)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 172 def self.minor_already_present?(minors, new) result = false minors.each do |el| if el.include?(new) result = true end end result end
run_versions(supplied_date)
click to toggle source
# File lib/portal_gun/ruby_versions.rb, line 194 def self.run_versions(supplied_date) unless correct_date?(supplied_date) puts "\n\n\nINVALID DATE FORMAT. Try '2.days.ago' or '2012-03-12'\n\n\n\n" exit end supplied_date = eval(supplied_date) minors = [] versions = [] PortalGun::RUBY_VERSIONS.reverse_each do |el| if latest?(supplied_date, Date.parse(el[0])) unless minor_already_present?(minors, minor(el[1])) minors << minor(el[1]) versions << el[1] end end break if versions.length == 3 end # puts "Here are the minor releases that were the most valid as of #{supplied_date}:" # versions.each_with_index do |version, index| # puts "[#{index}]: #{version}" # end # result = 'invalid' # while result == 'invalid' # puts 'Please enter which version you wish to use:' # result = gets.chomp # unless [0,1,2].include?(result.to_i) # result = 'invalid' # end # end # versions[result.to_i] versions end