Class: BostonMarathon::ResultSet

Inherits:
Array
  • Object
show all
Defined in:
lib/boston_marathon/result_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResultSet

Returns a new instance of ResultSet.



5
6
7
8
9
10
11
12
13
14
# File 'lib/boston_marathon/result_set.rb', line 5

def initialize(response)
  noko = Nokogiri::HTML(response.body)
  results = []
  headers = noko.css('.tr_header')
  infogrids = noko.css('.table_infogrid')
  unless headers.empty? || infogrids.empty?
    headers.zip(infogrids).map { |arr| results << Result.new(arr[0], arr[1]) }
  end
  replace(results)
end