class Emeril::Category
A category for a cookbook on the Community Site.
@author Fletcher Nichol <fnichol@nichol.ca>
Public Class Methods
for_cookbook(cookbook)
click to toggle source
Returns the category for the given cookbook on the Community Site or nil if it is not present.
@param [String] cookbook a cookbook name @return [String,nil] the cookbook category or nil if it is not present
on the Community site
# File lib/emeril/category.rb, line 20 def self.for_cookbook(cookbook) uri = URI("https://supermarket.getchef.com/api/v1/cookbooks/#{cookbook}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) JSON.parse(response.body)["category"] end