class Scraper

Public Class Methods

create_orgs() click to toggle source
# File lib/hockey_orgs/scraper.rb, line 7
def self.create_orgs #instantiates an "org" for every team in the NHL
    response = RestClient.get(URL)
    data = JSON.parse(response.body)["teams"]
    x = data.sort_by {|o| o["name"]}
    x.each.with_index(1) do |o, i|
       Org.new(i, o["name"], o["abbreviation"], o["venue"]["name"], o["venue"]["city"], o["firstYearOfPlay"], o["division"]["name"])
    end
end
list_orgs() click to toggle source
# File lib/hockey_orgs/scraper.rb, line 16
def self.list_orgs  #prints a numbered list of organizations for selection
    Org.all.each do |o| 
        #binding.pry
        puts "#{o.id}. #{o.name}"
    end
end