Skip to content

Instantly share code, notes, and snippets.

@rkumar
Created October 24, 2010 08:43
Show Gist options
  • Select an option

  • Save rkumar/643333 to your computer and use it in GitHub Desktop.

Select an option

Save rkumar/643333 to your computer and use it in GitHub Desktop.
#!/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