10 11 12 13 14 15 16
# File 'lib/mat/cli.rb', line 10 def get_data(query) if query.to_s.match(/^\d+$/) Mat.api.foodstuff(query) else Mat.api.foodstuffs(query) end end
18 19 20 21 22
# File 'lib/mat/cli.rb', line 18 def search(query) puts JSON.pretty_generate get_data(query) rescue Mat::HTTP::Exception warn "Nothing found" end