Skip to content

Instantly share code, notes, and snippets.

@byrichardpowell
Created July 26, 2012 13:04
Show Gist options
  • Save byrichardpowell/3181928 to your computer and use it in GitHub Desktop.
Save byrichardpowell/3181928 to your computer and use it in GitHub Desktop.
Ruby workshop ISBN
#!/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