On Mar 24, 2006, at 10:43 AM, semmons99 / gmail.com wrote:

> Is there a simpler way to do the following?

HighLine makes this kind of thing pretty simple:

Neo:~/Desktop$ ls
person.rb
Neo:~/Desktop$ ruby -rubygems person.rb
Name?  (last, first)  Gray, James
--- !ruby/struct:Person
first_name: James
last_name: Gray
Neo:~/Desktop$ cat person.rb
#!/usr/local/bin/ruby -w

require "highline/import"
require "yaml"

class Person < Struct.new(:first_name, :last_name)
   def self.parse( input )
     if input =~ /^\s*(\w+),\s*(\w+)\s*$/
       self.new($2, $1)
     else
       raise ArgumentError, "Invalid name format."
     end
   end
end

who = ask("Name?  (last, first)  ", Person)
y who

__END__

Hope that helps.

James Edward Gray II