class Udacity::UdacityAPI

Service for all Udacity API calls

Constants

UDACITY_URL

Public Class Methods

acquire_json_response() click to toggle source

get all courses info in json format through RESTful API

# File lib/share_learning/udacity_api.rb, line 10
def self.acquire_json_response
  response = HTTP.get(URI.parse(UDACITY_URL))
  JSON.parse(response)
end
retrieve_total_course_num() click to toggle source
# File lib/share_learning/udacity_api.rb, line 20
def self.retrieve_total_course_num
  return @total_course_num if @total_course_num

  # Retrieve the total number of courses on the catlog
  json_resp = acquire_json_response
  @total_course_num = json_resp['courses'].size
end
total_course_num() click to toggle source

get total courses number

# File lib/share_learning/udacity_api.rb, line 16
def self.total_course_num
  @total_course_num = retrieve_total_course_num
end