Created
October 24, 2010 08:43
-
-
Save rkumar/643333 to your computer and use it in GitHub Desktop.
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
| #!/usr/local/bin/ruby -w | |
| # prior to running create 2 files: | |
| # touch appemail.rb | |
| # touch appemaillb.rb | |
| # selecting the first gives an ambiguous error | |
| # basic_usage.rb | |
| # | |
| # Created by James Edward Gray II on 2005-04-28. | |
| # Copyright 2005 Gray Productions. All rights reserved. | |
| require "rubygems" | |
| require "highline/import" | |
| require "yaml" | |
| contacts = [ ] | |
| begin | |
| entry = Hash.new | |
| # basic output | |
| say("Enter a contact:") | |
| entry[:file] = ask("File? ", Pathname) do |q| | |
| #q.readline = true | |
| end | |
| # basic input | |
| contacts << entry | |
| # shortcut for yes and no questions | |
| end while agree("Enter another contact? ", true) | |
| if agree("Save these contacts? ", true) | |
| file_name = "x" | |
| File.open("#{file_name}.yaml", "w") { |file| YAML.dump(contacts, file) } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment