Loi Tran9,053 Points
print_results a part of the public domain?
Hey guys, does anyone here know if 'print_results' is in the public domain? I don't know why this isn't executing. code. https://gist.github.com/Lvtran1987/d6322db131c037045184 The only credible source I found/am familiar with says yes, however the github link it gives us is no longer a working page, so I'm pretty sure the page has been removed, unless github now blows and cant program well? Haha. Rubydoc page http://www.rubydoc.info/github/opscode/chef/Chef%2FKnife%2FList%3Aprint_results missing page https://github.com/chef/chef/blob/Chef%2FKnife%2FList%3Aprint_results/lib/chef/knife/list.rb#L123
Ah ha! Sorry, I was just looking at the top-level forum while drinking my morning coffee.
If Jason uses it, it's almost certainly got to be a method he's already written somewhere. I took a quick peek at the course, and it looks like the print_results method is included in the Teacher's Notes section of the Searching by Phone Number video:
def print_results(search, results) puts search results.each do |contact| puts contact.to_s('full_name') contact.print_phone_numbers contact.print_addresses puts "\n" end end
Hi! You've linked to some documentation for a method that's part of third-party program called Chef, which is written in Ruby but not actually part of Ruby itself.
Unless you've specifically added a third-party program in your code, you'll want to stick to using methods that are either part of Ruby itself or ones you've written as part of your program. Documentation for the core Ruby methods is here: http://ruby-doc.org/
In your case, you probably want to use the 'puts' or 'print' methods to output to the screen. You might also want to use a loop of some kind to go through each element of the results array, outputting each in turn.
Loi Tran9,053 Points
Greg, I understand everything you said. And I have tried to do the puts and print method. However the print_result is part of a query. This is the address book exercise we do in Ruby. If it isn't a part of the public domain why does Jason use it..? He uses it in the exercise when we're trying to add the method to our address_book which allows us to find_by_address.
Thanks for taking the time to respond!