Top Level Namespace

Defined Under Namespace

Classes: Car, MakeDoesNotExist, ModelDoesNotExist, Trim

Instance Method Summary collapse

Instance Method Details

#get_makesObject



21
22
23
24
# File 'lib/autostats.rb', line 21

def get_makes()
	car_page = Nokogiri::HTML(open("http://autos.aol.com"))
  makes = car_page.xpath("//div[@id = 'car_search_research_makes']/ul/li/a").collect{ |make| make.text + "\n" }
end

#get_models(make) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/autostats.rb', line 26

def get_models(make)
	car_page = Nokogiri::HTML(open("http://autos.aol.com/#{make.downcase}"))
    
  if car_page.xpath("//title").text == "Site Map - AOL Autos"
    puts "make #{make} does not exist"
    raise MakeDoesNotExist
  end
  
  models = car_page.xpath("//li[@class = 'sub_title']/a")
  model_name_list = []
  models.each do |model|
    model_name_list <<  model.text[(6 + make.size)..model.text.size] # strip year and make from text
  end
  model_name_list  
end