class Route attr_accessor :id, :link, :name def initialize(name, link) @name, @link = name, link.gsub('direction', 'stops') @id = @link.split("/")[-2] end # Returns array of instantiated Stops associated with Route def stops(link = @link) @stops = Wombat.crawl { base_url ROOT path link stops "xpath=//li[@class='arrow']/a[contains(@href, '/stops/')]", :iterator do name "xpath=./text()" href "xpath=./@href" end }['stops'].map { |s| Stop.new(s['name'], s['href']) } unless @stops @stops end end