This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date = Date.new(2011, 6, 9) | |
date.stamp("March 1, 1999") #=> "June 9, 2011" | |
date.stamp("Jan 1, 1999") #=> "Jun 9, 2011" | |
date.stamp("Jan 01") #=> "Jun 09" | |
date.stamp("Sunday, May 1, 2000") #=> "Thursday, June 9, 2011" | |
date.stamp("Sun Aug 5") #=> "Thu Jun 9" | |
date.stamp("12/31/99") #=> "06/09/11" | |
date.stamp("DOB: 12/31/2000") #=> "DOB: 06/09/2011" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add leading zeros to a number | |
def zero_pad(target_length, input_string) | |
pad_length = target_length - input_string.length | |
"0" * pad_length + input | |
end | |
# convert a number to binary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove comments, whitespace, newlines, and returns | |
# Use line.gsub! to modify the actual line instead of just returning the result | |
@input = line.gsub(/\t|\s|\n|\r|\/{2}.*$/, '') | |
# Then, once all of the crap is gone make sure to skip empty lines | |
if([email protected]?) |