Tuesday, April 8, 2014

Changes 4/8/14

Github:

  • Learned about modifying/deleting already existing commits

Ruby/Regular Expressions:

  • Began working on adding a preference for either reedtech or google's servers
  • I wanted to do it as elegantly as possible, so I took a long time and didn't finish
  • Basically, the download flag functions as it did, but now one can do download-reed(tech) or download-goog(le). 
  • This will then be passed to the url generator.

Code:

  1. #should_download = actions.empty? || (actions.include? "download") # old line of code
    # new lines of code:
    
    
    should_download = false
    server_preference = "goog" # Default to google
    unless actions.empty?
      actions.each do |action| # Actions is an array of launch options, ex: ["download-goog", "unzip", "extract"]
        should_download   = !(action.match /download/).nil? # is there a better way to evaluate false to nil and true to not nil?
        
        if should_download # break once the download option has been found
          server_preference = action.match(/goog|reed/).to_s # Sets server preference to "goog" or "reed" dependent on dl suffix
          break
        end 
      end
    end

No comments:

Post a Comment