Created
July 26, 2012 13:04
-
-
Save byrichardpowell/3181928 to your computer and use it in GitHub Desktop.
Ruby workshop ISBN
This file contains 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
#!/usr/bin/env ruby | |
isbn_array = [] | |
def to_isbn string | |
if ( string.gsub("\n", "") ) | |
string.gsub!("\n", "") | |
end | |
if ( string.gsub!(" ", "") ) | |
string.gsub!(" ", "") | |
end | |
if ( string.gsub!("-", "") ) | |
string.gsub!("-", "") | |
end | |
string | |
end | |
File.open('isbn_list.txt').each_line do |line| | |
puts line | |
puts '====' | |
isbn_array.push( to_isbn( line ) ) | |
end | |
puts isbn_array.inspect | |
// ["9780596516178", "9781430223634", "9780321584106", "9780321743121", "9781934356470", "9780321490452"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment